WaterKnight commited on
Commit
2e697e2
1 Parent(s): 9ba5c76

Image features rebuild.

Browse files
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  from io import BytesIO
3
  import requests
4
  from datetime import datetime
 
5
 
6
  # Interface utilities
7
  import gradio as gr
@@ -52,7 +53,8 @@ def image_from_text(text_input):
52
  similarities = list((text_features @ photo_features.T).squeeze(0))
53
 
54
  ## Return best image :)
55
- idx = sorted(zip(similarities, range(photo_features.shape[0])), key=lambda x: x[0], reverse=True)[0][1]
 
56
  photo_id = photo_ids[idx]
57
  photo_data = photos[photos["photo_id"] == photo_id].iloc[0]
58
 
 
2
  from io import BytesIO
3
  import requests
4
  from datetime import datetime
5
+ import random
6
 
7
  # Interface utilities
8
  import gradio as gr
 
53
  similarities = list((text_features @ photo_features.T).squeeze(0))
54
 
55
  ## Return best image :)
56
+ idx = sorted(zip(similarities, range(photo_features.shape[0])), key=lambda x: x[0], reverse=True)
57
+ idx = idx[random.randint(0,4)][1]
58
  photo_id = photo_ids[idx]
59
  photo_data = photos[photos["photo_id"] == photo_id].iloc[0]
60
 
unsplash-dataset/features.npy CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:14ef8a96e6b6adae89432ab046909ab600b5793ba47f2c352168696e7eb9dfb0
3
- size 51191936
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f375dcc5291457739bccad957f9a418fa7fef87f2c68acc487c58d8bb7672b26
3
+ size 50995328
unsplash-dataset/photo_ids.csv CHANGED
The diff for this file is too large to render. See raw diff