Spaces:
Runtime error
Runtime error
Ceyda Cinarel
commited on
Commit
·
7dbbdfd
1
Parent(s):
6d30f20
add calculating spinner
Browse files
app.py
CHANGED
@@ -117,16 +117,20 @@ query_images = q_cols[2].file_uploader("(optional) Upload images to rank them",t
|
|
117 |
|
118 |
if query_images:
|
119 |
st.write("Ranking your uploaded images with respect to input text:")
|
120 |
-
|
|
|
121 |
else:
|
122 |
st.write("Found these images within validation set:")
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
|
127 |
show_gif=st.checkbox("Play GIFs",value=True,help="Will play the original animation. Only first frame is used in training!")
|
128 |
ext = "jpg" if not show_gif else "gif"
|
129 |
res_cols=st.beta_columns(col_count)
|
|
|
|
|
130 |
for i,(id_, dist) in enumerate(zip(ids, dists)):
|
131 |
j=i%col_count
|
132 |
with res_cols[j]:
|
|
|
117 |
|
118 |
if query_images:
|
119 |
st.write("Ranking your uploaded images with respect to input text:")
|
120 |
+
with st.spinner("Calculating..."):
|
121 |
+
ids, dists = query_with_images(query_images,query_text)
|
122 |
else:
|
123 |
st.write("Found these images within validation set:")
|
124 |
+
with st.spinner("Calculating..."):
|
125 |
+
proc = processor(text=[query_text], images=None, return_tensors="jax", padding=True)
|
126 |
+
vec = np.asarray(model.get_text_features(**proc))
|
127 |
+
ids, dists = image_index.knnQuery(vec, k=top_k)
|
128 |
|
129 |
show_gif=st.checkbox("Play GIFs",value=True,help="Will play the original animation. Only first frame is used in training!")
|
130 |
ext = "jpg" if not show_gif else "gif"
|
131 |
res_cols=st.beta_columns(col_count)
|
132 |
+
|
133 |
+
|
134 |
for i,(id_, dist) in enumerate(zip(ids, dists)):
|
135 |
j=i%col_count
|
136 |
with res_cols[j]:
|