Spaces:
Runtime error
Runtime error
Samuel Schmidt
commited on
Commit
·
3ae9394
1
Parent(s):
6d93dbe
Merged dataset
Browse files- src/app.py +10 -8
src/app.py
CHANGED
@@ -98,14 +98,20 @@ def get_neighbors(query_image, selected_descriptor, selected_distance, top_k=5):
|
|
98 |
'lbp_embeddings', qi_embedding, k=top_k)
|
99 |
images = retrieved_examples['image']
|
100 |
return images
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
else:
|
102 |
print("This descriptor is not yet supported :(")
|
103 |
return []
|
104 |
|
105 |
|
106 |
-
def load_cbir_dataset(datasetname, size=1000):
|
107 |
-
pass
|
108 |
-
|
109 |
# Define the Gradio Interface
|
110 |
|
111 |
with gr.Blocks() as demo:
|
@@ -130,11 +136,7 @@ with gr.Blocks() as demo:
|
|
130 |
with gr.Row():
|
131 |
descr_dropdown = gr.Dropdown(["Color Descriptor", "LBP", "CLIP"], value="LBP", label="Please choose an descriptor")
|
132 |
dist_dropdown = gr.Dropdown(["FAISS", "Chi-squared", "Euclid"], value="FAISS", label="Please choose a distance measure")
|
133 |
-
|
134 |
-
["huggan/CelebA-faces", "EIT/cbir-eit"],
|
135 |
-
value="huggan/CelebA-faces",
|
136 |
-
label="Please select a dataset"
|
137 |
-
)
|
138 |
btn.click(get_neighbors, inputs=[image_input, descr_dropdown, dist_dropdown], outputs=[gallery_output])
|
139 |
|
140 |
|
|
|
98 |
'lbp_embeddings', qi_embedding, k=top_k)
|
99 |
images = retrieved_examples['image']
|
100 |
return images
|
101 |
+
if "LBPColor" == selected_descriptor:
|
102 |
+
lbp_model = LBPImageEncoder(8,2)
|
103 |
+
cd = ColorDescriptor((8, 12, 3))
|
104 |
+
qi_embedding = merge_features(lbp_model.describe(query_image), cd.describe(query_image))
|
105 |
+
scores, retrieved_examples = dataset_with_embeddings.get_nearest_examples(
|
106 |
+
'lbp_color_embeddings', qi_embedding, k=top_k
|
107 |
+
)
|
108 |
+
|
109 |
+
|
110 |
else:
|
111 |
print("This descriptor is not yet supported :(")
|
112 |
return []
|
113 |
|
114 |
|
|
|
|
|
|
|
115 |
# Define the Gradio Interface
|
116 |
|
117 |
with gr.Blocks() as demo:
|
|
|
136 |
with gr.Row():
|
137 |
descr_dropdown = gr.Dropdown(["Color Descriptor", "LBP", "CLIP"], value="LBP", label="Please choose an descriptor")
|
138 |
dist_dropdown = gr.Dropdown(["FAISS", "Chi-squared", "Euclid"], value="FAISS", label="Please choose a distance measure")
|
139 |
+
|
|
|
|
|
|
|
|
|
140 |
btn.click(get_neighbors, inputs=[image_input, descr_dropdown, dist_dropdown], outputs=[gallery_output])
|
141 |
|
142 |
|