diff options
-rw-r--r-- | evaluate.py | 22 |
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) |