bgaspra commited on
Commit
68ed7d4
·
verified ·
1 Parent(s): 59efe48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -125,7 +125,12 @@ def recommend(image):
125
  # Display images with matplotlib
126
  display_images(recommended_images, recommended_model_names, recommended_distances)
127
 
128
- return result
 
 
 
 
 
129
 
130
  def display_images(image_paths, model_names, distances):
131
  plt.figure(figsize=(20, 10))
@@ -139,12 +144,10 @@ def display_images(image_paths, model_names, distances):
139
 
140
  interface = gr.Interface(
141
  fn=recommend,
142
- inputs=gr.Image(type="pil"), # Updated input component
143
- outputs=gr.Text(), # Updated output component
144
  title="Image Recommendation System",
145
  description="Upload an image and get 5 recommended similar images with model names and distances."
146
  )
147
 
148
- interface.launch()
149
-
150
  interface.launch()
 
125
  # Display images with matplotlib
126
  display_images(recommended_images, recommended_model_names, recommended_distances)
127
 
128
+ # Prepare text output for copying
129
+ text_output = ""
130
+ for model_name, distance in zip(recommended_model_names, recommended_distances):
131
+ text_output += f"Model Name: {model_name}, Distance: {distance:.2f}\n"
132
+
133
+ return text_output
134
 
135
  def display_images(image_paths, model_names, distances):
136
  plt.figure(figsize=(20, 10))
 
144
 
145
  interface = gr.Interface(
146
  fn=recommend,
147
+ inputs=gr.Image(type="pil"),
148
+ outputs=gr.Textbox(), # Use Textbox for better text display
149
  title="Image Recommendation System",
150
  description="Upload an image and get 5 recommended similar images with model names and distances."
151
  )
152
 
 
 
153
  interface.launch()