diff options
author | Vasil Zlatanov <v@skozl.com> | 2019-02-04 17:36:00 +0000 |
---|---|---|
committer | Vasil Zlatanov <v@skozl.com> | 2019-02-04 17:36:00 +0000 |
commit | b140cb09dd8d10d11cbbda46e81231bb1fc4d179 (patch) | |
tree | 5fe72c0b5a554619dbd8fa2355d8c72a92a5aeb6 | |
parent | e6799b4716e54130deb06cec098ee62984dbfab4 (diff) | |
download | e4-vision-b140cb09dd8d10d11cbbda46e81231bb1fc4d179.tar.gz e4-vision-b140cb09dd8d10d11cbbda46e81231bb1fc4d179.tar.bz2 e4-vision-b140cb09dd8d10d11cbbda46e81231bb1fc4d179.zip |
Use desc_sel for KMeans generation
-rwxr-xr-x | evaluate.py | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/evaluate.py b/evaluate.py index 6b8fc80..b4d4a33 100755 --- a/evaluate.py +++ b/evaluate.py @@ -14,24 +14,13 @@ from sklearn.cluster import KMeans data = np.load(DATA_FILE) train = data['desc_tr'] +train_part = data['desc_sel'].T -# Train part will contain 15 000 descriptors to generate KMeans -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) - +print("Computing KMeans with", train_part.shape[0], "keywords") 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].T),minlength=CLUSTER_CNT) |