diff options
author | nunzip <np.scarh@gmail.com> | 2019-02-04 17:30:46 +0000 |
---|---|---|
committer | nunzip <np.scarh@gmail.com> | 2019-02-04 17:30:46 +0000 |
commit | 1148a979b58be97111098307d3b7015d9b5b12c4 (patch) | |
tree | 03023d5ff719948c65c226e4c0e7e31a5ebb75ed | |
parent | a95fc4c4050636ed5aa06e49842bc52666b1b7bf (diff) | |
parent | e6799b4716e54130deb06cec098ee62984dbfab4 (diff) | |
download | e4-vision-1148a979b58be97111098307d3b7015d9b5b12c4.tar.gz e4-vision-1148a979b58be97111098307d3b7015d9b5b12c4.tar.bz2 e4-vision-1148a979b58be97111098307d3b7015d9b5b12c4.zip |
t pushMerge branch 'master' of skozl.com:e4-vision
-rwxr-xr-x[-rw-r--r--] | evaluate.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/evaluate.py b/evaluate.py index 309326e..6b8fc80 100644..100755 --- a/evaluate.py +++ b/evaluate.py @@ -1,8 +1,9 @@ +#!/usr/bin/python # EE4 Selected Topics From Computer Vision Coursework # Vasil Zlatanov, Nunzio Pucci DATA_FILE = 'data.npz' -CLUSTER_CNT = 1337 +CLUSTER_CNT = 256 KMEAN_PART = 33 import numpy as np @@ -12,19 +13,34 @@ from sklearn.cluster import KMeans data = np.load(DATA_FILE) -train = data['train'] +train = data['desc_tr'] # Train part will contain 15 000 descriptors to generate KMeans -part_idx = np.random.random_integers(train.shape[1]) -train_part = np.vstack(train[:][part_idx][300:1300]) +part_idx = np.random.randint(train.shape[1]) + +parts = [] +for i in train[:, part_idx]: + parts.append(i.T[300:1300]) + +train_part = np.vstack(parts) + +print(train_part.shape) kmeans = KMeans(n_clusters=CLUSTER_CNT, random_state=0).fit(train_part) +print("Generating histograms") histogram = np.zeros((train.shape[0], train.shape[1],CLUSTER_CNT)) -for i in range(train.shape[0]) - for j in range(train.shape[1]) - histogram[i][j] = np.bincount(kmeans.predict(train[i][j]) +for i in range(train.shape[0]): + for j in range(train.shape[1]): + histogram[i][j] = np.bincount(kmeans.predict(train[i][j].T),minlength=CLUSTER_CNT) print(histogram.shape) + +plt.hist(histogram[1][5]) +plt.show() +plt.hist(histogram[3][2]) +plt.show() +plt.hist(histogram[7][8]) +plt.show() |