Spaces:
Runtime error
Runtime error
Ceyda Cinarel
commited on
Commit
•
b10f4fc
1
Parent(s):
07c95a1
remove debug
Browse files
app.py
CHANGED
@@ -34,6 +34,9 @@ with st.sidebar.beta_expander("Motivation",expanded=True):
|
|
34 |
)
|
35 |
top_k=st.sidebar.slider("Show top-K", min_value=1, max_value=50, value=20)
|
36 |
col_count=4
|
|
|
|
|
|
|
37 |
show_val=st.sidebar.button("show all validation set images")
|
38 |
if show_val:
|
39 |
cols=st.sidebar.beta_columns(col_count)
|
@@ -58,8 +61,7 @@ def load_image_index():
|
|
58 |
|
59 |
return index
|
60 |
|
61 |
-
|
62 |
-
file_names.sort()
|
63 |
|
64 |
image_index = load_image_index()
|
65 |
model, processor = load_model()
|
@@ -85,17 +87,17 @@ def query_with_images(query_images,query_text):
|
|
85 |
inputs["pixel_values"] = jnp.transpose(inputs["pixel_values"], axes=[0, 2, 3, 1])
|
86 |
outputs = model(**inputs)
|
87 |
logits_per_image = outputs.logits_per_image.reshape(-1)
|
88 |
-
st.write(logits_per_image)
|
89 |
probs = jax.nn.softmax(logits_per_image)
|
90 |
-
st.write(probs)
|
91 |
-
st.write(list(zip(images,probs)))
|
92 |
results = sorted(list(zip(images,probs)),key=lambda x: x[1], reverse=True)
|
93 |
-
st.write(results)
|
94 |
return zip(*results)
|
95 |
|
96 |
q_cols=st.beta_columns([5,2,5])
|
97 |
|
98 |
-
examples = ["I'm so scared right now"," I got the job 🎉","
|
99 |
example_input = q_cols[0].radio("Example Queries :",examples,index=4)
|
100 |
q_cols[2].markdown(
|
101 |
"""
|
|
|
34 |
)
|
35 |
top_k=st.sidebar.slider("Show top-K", min_value=1, max_value=50, value=20)
|
36 |
col_count=4
|
37 |
+
file_names=os.listdir("./imgs")
|
38 |
+
file_names.sort()
|
39 |
+
|
40 |
show_val=st.sidebar.button("show all validation set images")
|
41 |
if show_val:
|
42 |
cols=st.sidebar.beta_columns(col_count)
|
|
|
61 |
|
62 |
return index
|
63 |
|
64 |
+
|
|
|
65 |
|
66 |
image_index = load_image_index()
|
67 |
model, processor = load_model()
|
|
|
87 |
inputs["pixel_values"] = jnp.transpose(inputs["pixel_values"], axes=[0, 2, 3, 1])
|
88 |
outputs = model(**inputs)
|
89 |
logits_per_image = outputs.logits_per_image.reshape(-1)
|
90 |
+
# st.write(logits_per_image)
|
91 |
probs = jax.nn.softmax(logits_per_image)
|
92 |
+
# st.write(probs)
|
93 |
+
# st.write(list(zip(images,probs)))
|
94 |
results = sorted(list(zip(images,probs)),key=lambda x: x[1], reverse=True)
|
95 |
+
# st.write(results)
|
96 |
return zip(*results)
|
97 |
|
98 |
q_cols=st.beta_columns([5,2,5])
|
99 |
|
100 |
+
examples = ["OMG that is disgusting","I'm so scared right now"," I got the job 🎉","Congratulations to all the flax-community week teams","You're awesome","I love you ❤️"]
|
101 |
example_input = q_cols[0].radio("Example Queries :",examples,index=4)
|
102 |
q_cols[2].markdown(
|
103 |
"""
|