ubamba98 commited on
Commit
80065f6
1 Parent(s): 54b0744

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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
- photo_data = photos[photos["photo_id"] == photo_id].iloc[0]
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