SRDdev commited on
Commit
f384b4c
·
verified ·
1 Parent(s): aa6b115

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -68,7 +68,7 @@ def image_search(query, corpus, max_results=3):
68
  dot_product2 = dot_product2 / np.max(dot_product2, axis=0, keepdims=True)
69
  dot_product -= np.max(np.maximum(dot_product2, 0), axis=1)
70
 
71
- results = np.argsort(dot_product)[-1 : -max_results - 1 : -1]
72
  return [
73
  (
74
  df[k].iloc[i]["path"],
@@ -113,14 +113,8 @@ def main():
113
  unsafe_allow_html=True,
114
  )
115
 
116
- st.markdown("# CLIP Image Search")
117
- st.sidebar.info("""
118
- **Enter your query and hit enter**
119
 
120
- - Click image to find similar images
121
- - Use ';'' to combine multiple queries
122
- - Use 'EXCLUDING' to exclude a query
123
- """)
124
 
125
  if "query" in st.session_state:
126
  query = st.sidebar.text_input("Query", value=st.session_state["query"])
@@ -152,5 +146,13 @@ def main():
152
  st.session_state["query"] = f"[{corpus}:{results[clicked][2]}]"
153
  st.experimental_rerun()
154
 
 
 
 
 
 
 
 
 
155
  if __name__ == "__main__":
156
  main()
 
68
  dot_product2 = dot_product2 / np.max(dot_product2, axis=0, keepdims=True)
69
  dot_product -= np.max(np.maximum(dot_product2, 0), axis=1)
70
 
71
+ results = np.argsort(dot_product)[::-1]
72
  return [
73
  (
74
  df[k].iloc[i]["path"],
 
113
  unsafe_allow_html=True,
114
  )
115
 
116
+ st.markdown("# 🔍 CLIP Image Search")
 
 
117
 
 
 
 
 
118
 
119
  if "query" in st.session_state:
120
  query = st.sidebar.text_input("Query", value=st.session_state["query"])
 
146
  st.session_state["query"] = f"[{corpus}:{results[clicked][2]}]"
147
  st.experimental_rerun()
148
 
149
+ st.sidebar.info("""
150
+ Enter your query and hit enter
151
+
152
+ - Click image to find similar images
153
+ - Use ';'' to combine multiple queries
154
+ - Use 'EXCLUDING' to exclude a query
155
+ """)
156
+
157
  if __name__ == "__main__":
158
  main()