Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -93,9 +93,19 @@ def demo_retrieval():
|
|
93 |
with tab_img:
|
94 |
with st.form("rimgform"):
|
95 |
k = st.slider("Number of items to retrieve", 1, 100, 16, key='rimage')
|
96 |
-
|
97 |
if st.form_submit_button("Retrieve with Image"):
|
98 |
prog.progress(0.49, "Computing Embeddings")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
with tab_text:
|
101 |
with st.form("rtextform"):
|
|
|
93 |
with tab_img:
|
94 |
with st.form("rimgform"):
|
95 |
k = st.slider("Number of items to retrieve", 1, 100, 16, key='rimage')
|
96 |
+
pic = st.file_uploader("Upload an Image", key='rimageinput')
|
97 |
if st.form_submit_button("Retrieve with Image"):
|
98 |
prog.progress(0.49, "Computing Embeddings")
|
99 |
+
img = Image.open(pic)
|
100 |
+
st.image(img)
|
101 |
+
device = clip_model.device
|
102 |
+
tn = clip_prep(images=[img], return_tensors="pt").to(device)
|
103 |
+
enc = clip_model.get_image_features(pixel_values=tn['pixel_values'].type(half)).float().cpu()
|
104 |
+
|
105 |
+
prog.progress(0.7, "Running Retrieval")
|
106 |
+
retrieval_results(retrieval.retrieve(enc, k, sim_th, filter_fn))
|
107 |
+
|
108 |
+
prog.progress(1.0, "Idle")
|
109 |
|
110 |
with tab_text:
|
111 |
with st.form("rtextform"):
|