bgaspra commited on
Commit
98d3e8a
·
verified ·
1 Parent(s): 61e280c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -109,16 +109,15 @@ def display_images(image_paths, model_names, distances):
109
 
110
  def recommend_images(img):
111
  recommended_images, recommended_model_names, recommended_distances = get_recommendations(img, model, nbrs, image_paths, model_names)
112
- return [Image.open(img_path) for img_path in recommended_images], [model_name for model_name in recommended_model_names], [distance for distance in recommended_distances]
 
 
 
113
 
114
  iface = gr.Interface(
115
  fn=recommend_images,
116
  inputs=gr.Image(label="Upload an image"),
117
- outputs=[
118
- gr.Gallery(label="Recommended Images", show_label=False),
119
- gr.Textbox(label="Model Names", lines=5),
120
- gr.Textbox(label="Distances", lines=5)
121
- ],
122
  title="Image Recommendation System",
123
  description="Upload an image and get recommendations based on similarity."
124
  )
 
109
 
110
  def recommend_images(img):
111
  recommended_images, recommended_model_names, recommended_distances = get_recommendations(img, model, nbrs, image_paths, model_names)
112
+ recommendations = []
113
+ for i in range(len(recommended_images)):
114
+ recommendations.append(f"Rekomendasi {i+1}:\nGambar: {Image.open(recommended_images[i])}\nModel: {recommended_model_names[i]}\nEuclidian Distance: {recommended_distances[i]:.2f}")
115
+ return recommendations
116
 
117
  iface = gr.Interface(
118
  fn=recommend_images,
119
  inputs=gr.Image(label="Upload an image"),
120
+ outputs=gr.Textbox(label="Rekomendasi", lines=10),
 
 
 
 
121
  title="Image Recommendation System",
122
  description="Upload an image and get recommendations based on similarity."
123
  )