From abe9e11be8c0a8ebf05506067d42b1fa832be220 Mon Sep 17 00:00:00 2001 From: ed-fish Date: Sat, 2 Oct 2021 11:09:53 +0100 Subject: [PATCH 1/2] Fix issue with use_cache --- pixplot/pixplot.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pixplot/pixplot.py b/pixplot/pixplot.py index d512b7cd..13cc7b66 100644 --- a/pixplot/pixplot.py +++ b/pixplot/pixplot.py @@ -580,18 +580,26 @@ def get_inception_vectors(**kwargs): vector_path = os.path.join(vector_dir, clean_filename(i.path) + '.npy') if os.path.exists(vector_path) and kwargs['use_cache']: vec = np.load(vector_path) + if len(vec) < 2: + vec = np.expand_dims(vec, 0) else: im = preprocess_input( img_to_array( i.original.resize((299,299)) ) ) vec = model.predict(np.expand_dims(im, 0)).squeeze() np.save(vector_path, vec) vecs.append(vec) progress_bar.update(1) - return np.array(vecs) + + if os.path.exists(vector_path) and kwargs['use_cache']: + vecs = np.stack(vecs, 0).squeeze() + return vecs + else: + return np.array(vecs) def get_umap_layout(**kwargs): '''Get the x,y positions of images passed through a umap projection''' vecs = kwargs['vecs'] + print("VECTOR SHAPE", vecs.shape) w = PCA(n_components=min(100, len(vecs))).fit_transform(vecs) # single model umap if len(kwargs['n_neighbors']) == 1 and len(kwargs['min_dist']) == 1: From 2596ac319b8058539b99804ab186a9471cdc2902 Mon Sep 17 00:00:00 2001 From: ed-fish Date: Sat, 2 Oct 2021 11:22:44 +0100 Subject: [PATCH 2/2] remove debugging print statement --- pixplot/pixplot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pixplot/pixplot.py b/pixplot/pixplot.py index 13cc7b66..8c2103e4 100644 --- a/pixplot/pixplot.py +++ b/pixplot/pixplot.py @@ -599,7 +599,6 @@ def get_inception_vectors(**kwargs): def get_umap_layout(**kwargs): '''Get the x,y positions of images passed through a umap projection''' vecs = kwargs['vecs'] - print("VECTOR SHAPE", vecs.shape) w = PCA(n_components=min(100, len(vecs))).fit_transform(vecs) # single model umap if len(kwargs['n_neighbors']) == 1 and len(kwargs['min_dist']) == 1: