Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,8 +36,10 @@ def find_similar(image):
|
|
| 36 |
## Return best image :)
|
| 37 |
idx = sorted(zip(similarities, range(photo_features.shape[0])), key=lambda x: x[0], reverse=True)[0][1]
|
| 38 |
photo_id = photo_ids[idx]
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
response = requests.get(photo_data["photo_image_url"] + "?w=640")
|
| 42 |
img = PILIMAGE.open(BytesIO(response.content))
|
| 43 |
return img
|
|
|
|
| 36 |
## Return best image :)
|
| 37 |
idx = sorted(zip(similarities, range(photo_features.shape[0])), key=lambda x: x[0], reverse=True)[0][1]
|
| 38 |
photo_id = photo_ids[idx]
|
| 39 |
+
try:
|
| 40 |
+
photo_data = photos[photos["photo_id"] == photo_id].iloc[0]
|
| 41 |
+
except:
|
| 42 |
+
photo_data = photos.iloc[0]
|
| 43 |
response = requests.get(photo_data["photo_image_url"] + "?w=640")
|
| 44 |
img = PILIMAGE.open(BytesIO(response.content))
|
| 45 |
return img
|