Spaces:
Running
Running
Update helpers.py
Browse files- helpers.py +7 -4
helpers.py
CHANGED
@@ -84,8 +84,11 @@ def findCosineDistance(source_representation, test_representation):
|
|
84 |
|
85 |
def get_embeddings(model, imgs):
|
86 |
embeddings = []
|
87 |
-
for img in imgs:
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
91 |
return embeddings
|
|
|
84 |
|
85 |
def get_embeddings(model, imgs):
|
86 |
embeddings = []
|
87 |
+
for i, img in enumerate(imgs):
|
88 |
+
try:
|
89 |
+
img = np.expand_dims(np.array(img.resize((152,152))), axis = 0)
|
90 |
+
embedding = model.predict(img, verbose=0)[0]
|
91 |
+
embeddings.append(embedding)
|
92 |
+
except:
|
93 |
+
print(f"Error at {i}, skipping")
|
94 |
return embeddings
|