Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
import similarSearch
|
| 4 |
-
from PIL import Image
|
| 5 |
-
|
| 6 |
-
df = pd.read_csv('./gallery.csv')
|
| 7 |
|
| 8 |
# Function to find similar image IDs for a newly updated image
|
| 9 |
def find_similar_images(new_image):
|
| 10 |
# Placeholder for your code to find similar image IDs based on the new_image
|
| 11 |
similar_ids = similarSearch.predict(new_image) # Replace with the actual logic for finding similar IDs
|
|
|
|
| 12 |
return similar_ids
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
def display_images(image_ids):
|
| 16 |
-
images = []
|
| 17 |
-
captions = []
|
| 18 |
-
for img_id in image_ids:
|
| 19 |
-
image_path = df.loc[df['seller_img_id'] == img_id, 'img_path'].values[0]
|
| 20 |
-
image = Image.open(image_path)
|
| 21 |
-
images.append(image)
|
| 22 |
-
captions.append(img_id)
|
| 23 |
-
return images, captions
|
| 24 |
-
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=find_similar_images,
|
| 27 |
inputs=gr.inputs.Image(label="Upload Image"),
|
| 28 |
-
outputs=gr.outputs.
|
| 29 |
title="Image Similarity Finder",
|
| 30 |
description="Upload an image to find similar image IDs in the database."
|
| 31 |
)
|
| 32 |
|
|
|
|
| 33 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
import similarSearch
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Function to find similar image IDs for a newly updated image
|
| 6 |
def find_similar_images(new_image):
|
| 7 |
# Placeholder for your code to find similar image IDs based on the new_image
|
| 8 |
similar_ids = similarSearch.predict(new_image) # Replace with the actual logic for finding similar IDs
|
| 9 |
+
print(similar_ids)
|
| 10 |
return similar_ids
|
| 11 |
|
| 12 |
+
# Define Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
iface = gr.Interface(
|
| 14 |
fn=find_similar_images,
|
| 15 |
inputs=gr.inputs.Image(label="Upload Image"),
|
| 16 |
+
outputs=gr.outputs.JSON(label="Similar Image IDs"),
|
| 17 |
title="Image Similarity Finder",
|
| 18 |
description="Upload an image to find similar image IDs in the database."
|
| 19 |
)
|
| 20 |
|
| 21 |
+
# Launch the Gradio interface
|
| 22 |
iface.launch()
|