Update app.py
Browse files
app.py
CHANGED
|
@@ -97,17 +97,13 @@ def get_recommendations(img, n_neighbors=5):
|
|
| 97 |
recommended_model_names = [model_names[idx] for idx in indices.flatten()]
|
| 98 |
recommended_distances = distances.flatten()
|
| 99 |
|
| 100 |
-
return [Image.open(img_path) for img_path in recommended_images
|
| 101 |
|
| 102 |
# Gradio interface
|
| 103 |
-
def display_images(input_image):
|
| 104 |
-
recommended_images, recommended_model_names, recommended_distances = get_recommendations(input_image)
|
| 105 |
-
return [(img, f'{name}, Distance: {dist:.2f}') for img, name, dist in zip(recommended_images, recommended_model_names, recommended_distances)]
|
| 106 |
-
|
| 107 |
interface = gr.Interface(
|
| 108 |
-
fn=
|
| 109 |
inputs=gr.Image(type="pil"),
|
| 110 |
-
outputs=gr.
|
| 111 |
title="Image Recommendation System",
|
| 112 |
description="Upload an image and get similar images with their model names and distances."
|
| 113 |
)
|
|
|
|
| 97 |
recommended_model_names = [model_names[idx] for idx in indices.flatten()]
|
| 98 |
recommended_distances = distances.flatten()
|
| 99 |
|
| 100 |
+
return [(Image.open(img_path), f'{name}, Distance: {dist:.2f}') for img_path, name, dist in zip(recommended_images, recommended_model_names, recommended_distances)]
|
| 101 |
|
| 102 |
# Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
interface = gr.Interface(
|
| 104 |
+
fn=get_recommendations,
|
| 105 |
inputs=gr.Image(type="pil"),
|
| 106 |
+
outputs=gr.Gallery(label="Recommended Images"),
|
| 107 |
title="Image Recommendation System",
|
| 108 |
description="Upload an image and get similar images with their model names and distances."
|
| 109 |
)
|