Working version
Browse files
app.py
CHANGED
@@ -67,21 +67,22 @@ def process_dataset(dataset_name, dataset_split, dataset_column_image):
|
|
67 |
def compute(dataset_name, dataset_split, dataset_column_image, img):
|
68 |
img_dataset = process_dataset(dataset_name, dataset_split, dataset_column_image)
|
69 |
closest_idx, distances = find_closest_images(img, img_dataset)
|
70 |
-
return [img_dataset[i] for i in closest_idx]
|
71 |
|
72 |
|
73 |
with gr.Blocks() as demo:
|
74 |
gr.Markdown("# Find if your images are in a public dataset!")
|
75 |
with gr.Row():
|
76 |
with gr.Column(scale=1, min_width=600):
|
77 |
-
dataset_name = gr.Textbox(label="Enter the name of a dataset containing images")
|
78 |
-
dataset_split = gr.Textbox(label="Enter the split of this dataset to consider")
|
79 |
-
dataset_column_image = gr.Textbox(label="Enter the name of the column of this dataset that contains images")
|
80 |
img = gr.Image(label="Input your image that will be compared against images of the dataset", type="pil")
|
81 |
btn = gr.Button("Find").style(full_width=True)
|
82 |
|
83 |
with gr.Column(scale=2, min_width=600):
|
84 |
gallery_similar = gr.Gallery(label="similar images")
|
|
|
85 |
|
86 |
event = btn.click(compute, [dataset_name, dataset_split, dataset_column_image, img], gallery_similar)
|
87 |
|
|
|
67 |
def compute(dataset_name, dataset_split, dataset_column_image, img):
|
68 |
img_dataset = process_dataset(dataset_name, dataset_split, dataset_column_image)
|
69 |
closest_idx, distances = find_closest_images(img, img_dataset)
|
70 |
+
return [img_dataset[i][dataset_column_image] for i in closest_idx]
|
71 |
|
72 |
|
73 |
with gr.Blocks() as demo:
|
74 |
gr.Markdown("# Find if your images are in a public dataset!")
|
75 |
with gr.Row():
|
76 |
with gr.Column(scale=1, min_width=600):
|
77 |
+
dataset_name = gr.Textbox(label="Enter the name of a dataset containing images", value="huggan/few-shot-pokemon")
|
78 |
+
dataset_split = gr.Textbox(label="Enter the split of this dataset to consider", value="train")
|
79 |
+
dataset_column_image = gr.Textbox(label="Enter the name of the column of this dataset that contains images", value="image")
|
80 |
img = gr.Image(label="Input your image that will be compared against images of the dataset", type="pil")
|
81 |
btn = gr.Button("Find").style(full_width=True)
|
82 |
|
83 |
with gr.Column(scale=2, min_width=600):
|
84 |
gallery_similar = gr.Gallery(label="similar images")
|
85 |
+
gallery_similar.style(grid=3)
|
86 |
|
87 |
event = btn.click(compute, [dataset_name, dataset_split, dataset_column_image, img], gallery_similar)
|
88 |
|