Vivien commited on
Commit
6392199
1 Parent(s): 685c1fb

Improve presentation

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -194,11 +194,11 @@ def draw_reshape_encode(img, boxes, x, y):
194
  def get_html(url_list, encoded_images):
195
  html = "<div style='margin-top: 20px; max-width: 1200px; display: flex; flex-wrap: wrap; justify-content: space-evenly'>"
196
  for i in range(len(url_list)):
197
- title, link, encoded = url_list[i][1], url_list[i][2], encoded_images[i]
198
- html2 = f"<img title='{escape(title)}' style='height: {HEIGHT}px; margin: 5px' src='data:image/jpeg;base64,{encoded.decode()}'>"
199
- if len(link) > 0:
200
- html2 = f"<a href='{escape(link)}' target='_blank'>" + html2 + "</a>"
201
- html = html + html2
202
  html += "</div>"
203
  return html
204
 
@@ -206,13 +206,13 @@ def get_html(url_list, encoded_images):
206
  description = """
207
  # Search and Detect
208
 
209
- This demo illustrates how you can both retrieve images containing certain objects and locate these objects with a simple natural language query.
210
 
211
  **Enter your query and hit enter**
212
 
213
  **Tip 1**: if your query includes "/", the part left (resp. right) of "/" will be used to retrieve images (resp. locate objects). For example, if you want to retrieve pictures with several cats but locate individual cats, you can type "cats / cat".
214
 
215
- **Tip 2**: change the score threshold below to adjust the sensitivity of the object detection.
216
 
217
  *Built with OpenAI's [CLIP](https://openai.com/blog/clip/) model and Google's [OWL-ViT](https://arxiv.org/abs/2205.06230) model, 🤗 Hugging Face's [transformers library](https://huggingface.co/transformers/), [Streamlit](https://streamlit.io/), 25k images from [Unsplash](https://unsplash.com/) and 8k images from [The Movie Database (TMDB)](https://www.themoviedb.org/)*
218
 
@@ -232,7 +232,7 @@ def main():
232
  .block-container{
233
  max-width: 1200px;
234
  }
235
- div.row-widget.stRadio > div{
236
  flex-direction:row;
237
  display: flex;
238
  justify-content: center;
@@ -253,20 +253,17 @@ def main():
253
  #MainMenu {
254
  visibility: hidden;
255
  }
256
- footer {
257
- visibility: hidden;
258
- }
259
  </style>""",
260
  unsafe_allow_html=True,
261
  )
262
  st.sidebar.markdown(description)
263
- score_threshold = st.sidebar.slider(
264
- "Score threshold", min_value=0.01, max_value=0.3, value=0.1, step=0.01
265
- )
266
 
267
  _, c, _ = st.columns((1, 3, 1))
268
  query = c.text_input("", value="koala")
269
- corpus = st.radio("", ["Unsplash", "Movies"])
 
 
 
270
 
271
  if len(query) > 0:
272
  if "/" in query:
 
194
  def get_html(url_list, encoded_images):
195
  html = "<div style='margin-top: 20px; max-width: 1200px; display: flex; flex-wrap: wrap; justify-content: space-evenly'>"
196
  for i in range(len(url_list)):
197
+ title, encoded = url_list[i][1], encoded_images[i]
198
+ html = (
199
+ html
200
+ + f"<img title='{escape(title)}' style='height: {HEIGHT}px; margin: 5px' src='data:image/jpeg;base64,{encoded.decode()}'>"
201
+ )
202
  html += "</div>"
203
  return html
204
 
 
206
  description = """
207
  # Search and Detect
208
 
209
+ This demo illustrates how to both retrieve images containing certain objects and locate these objects with a simple text query.
210
 
211
  **Enter your query and hit enter**
212
 
213
  **Tip 1**: if your query includes "/", the part left (resp. right) of "/" will be used to retrieve images (resp. locate objects). For example, if you want to retrieve pictures with several cats but locate individual cats, you can type "cats / cat".
214
 
215
+ **Tip 2**: change the score threshold to adjust the sensitivity of the object detection step.
216
 
217
  *Built with OpenAI's [CLIP](https://openai.com/blog/clip/) model and Google's [OWL-ViT](https://arxiv.org/abs/2205.06230) model, 🤗 Hugging Face's [transformers library](https://huggingface.co/transformers/), [Streamlit](https://streamlit.io/), 25k images from [Unsplash](https://unsplash.com/) and 8k images from [The Movie Database (TMDB)](https://www.themoviedb.org/)*
218
 
 
232
  .block-container{
233
  max-width: 1200px;
234
  }
235
+ div.row-widget > div{
236
  flex-direction:row;
237
  display: flex;
238
  justify-content: center;
 
253
  #MainMenu {
254
  visibility: hidden;
255
  }
 
 
 
256
  </style>""",
257
  unsafe_allow_html=True,
258
  )
259
  st.sidebar.markdown(description)
 
 
 
260
 
261
  _, c, _ = st.columns((1, 3, 1))
262
  query = c.text_input("", value="koala")
263
+ corpus = c.radio("", ["Unsplash", "Movies"])
264
+ score_threshold = c.slider(
265
+ "Score threshold", min_value=0.01, max_value=0.1, value=0.03, step=0.01
266
+ )
267
 
268
  if len(query) > 0:
269
  if "/" in query: