aboutsummaryrefslogtreecommitdiff
path: root/evaluate.py
diff options
context:
space:
mode:
authorVasil Zlatanov <v@skozl.com>2019-02-04 16:52:54 +0000
committerVasil Zlatanov <v@skozl.com>2019-02-04 16:52:54 +0000
commit3d55b96e9c5a3abffe4662381b50251f96137805 (patch)
tree3cc4040f3c79a54b094bd1fc9288d7a0b207dca4 /evaluate.py
parent82d295c4693e17b71c52632740f4f98e141f8d49 (diff)
downloade4-vision-3d55b96e9c5a3abffe4662381b50251f96137805.tar.gz
e4-vision-3d55b96e9c5a3abffe4662381b50251f96137805.tar.bz2
e4-vision-3d55b96e9c5a3abffe4662381b50251f96137805.zip
Revise code to match exported format
Diffstat (limited to 'evaluate.py')
-rw-r--r--evaluate.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/evaluate.py b/evaluate.py
index 6504ec1..309326e 100644
--- a/evaluate.py
+++ b/evaluate.py
@@ -1,6 +1,7 @@
# EE4 Selected Topics From Computer Vision Coursework
# Vasil Zlatanov, Nunzio Pucci
+DATA_FILE = 'data.npz'
CLUSTER_CNT = 1337
KMEAN_PART = 33
@@ -9,16 +10,21 @@ import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
-train = []
-test = []
+data = np.load(DATA_FILE)
-train_part = np.hstack(train[0:KMEAN_PART])
+train = data['train']
+
+# 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])
kmeans = KMeans(n_clusters=CLUSTER_CNT, random_state=0).fit(train_part)
-codewords = []
-i = 0
-for image in train:
- codewords.append(np.bincount(kmeans.predict(image)
- print codewords[i].shape
+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])
+
+print(histogram.shape)