RobotJelly commited on
Commit
c36f360
·
1 Parent(s): 90348c5
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -28,13 +28,13 @@ photos = pd.read_csv("./photos.tsv000", sep="\t", header=0)
28
  # taking features vectors
29
  photo_features = np.load("./features.npy")
30
 
31
- def show_output_image(matched_images, photos) :
32
  image=[]
33
  for photo_id in matched_images:
34
  #photo_image_url = f"https://unsplash.com/photos/{photo_id}/download?w=280"
35
  #photo_image_url = f"https://unsplash.com/photos/{photo_id}?w=640"
36
  #photo_image_url = f"https://unsplash.com/photos/{photo_id}?ixid=2yJhcHBfaWQiOjEyMDd9&fm=jpg"
37
- photo_found = photos[photos["photo_id"] == photo_id].iloc[0]
38
  #response = requests.get(photo_found["photo_image_url"] + "?w=640")
39
  #response = requests.get(photo_image_url)
40
  #img = Image.open(BytesIO(response.content))
@@ -80,7 +80,7 @@ def image_search(search_text, search_image, option):
80
  #print(photo_image_url)
81
  #--------------------------#
82
 
83
- return show_output_image(matched_images, photos)
84
  elif option == "Image-To-Image":
85
  # Input Image for Search
86
  with torch.no_grad():
@@ -89,7 +89,7 @@ def image_search(search_text, search_image, option):
89
  # Find the matched Images
90
  matched_images = find_matches(image_feature, photo_features, photo_ids, 4)
91
  #is_input_image = True
92
- return show_output_image(matched_images, photos)
93
 
94
  gr.Interface(fn=image_search,
95
  inputs=[gr.inputs.Textbox(lines=7, label="Input Text"),
 
28
  # taking features vectors
29
  photo_features = np.load("./features.npy")
30
 
31
+ def show_output_image(matched_images) :
32
  image=[]
33
  for photo_id in matched_images:
34
  #photo_image_url = f"https://unsplash.com/photos/{photo_id}/download?w=280"
35
  #photo_image_url = f"https://unsplash.com/photos/{photo_id}?w=640"
36
  #photo_image_url = f"https://unsplash.com/photos/{photo_id}?ixid=2yJhcHBfaWQiOjEyMDd9&fm=jpg"
37
+ #photo_found = photos[photos["photo_id"] == photo_id].iloc[0]
38
  #response = requests.get(photo_found["photo_image_url"] + "?w=640")
39
  #response = requests.get(photo_image_url)
40
  #img = Image.open(BytesIO(response.content))
 
80
  #print(photo_image_url)
81
  #--------------------------#
82
 
83
+ return show_output_image(matched_images)
84
  elif option == "Image-To-Image":
85
  # Input Image for Search
86
  with torch.no_grad():
 
89
  # Find the matched Images
90
  matched_images = find_matches(image_feature, photo_features, photo_ids, 4)
91
  #is_input_image = True
92
+ return show_output_image(matched_images)
93
 
94
  gr.Interface(fn=image_search,
95
  inputs=[gr.inputs.Textbox(lines=7, label="Input Text"),