Vivien commited on
Commit
ba03fb2
β€’
1 Parent(s): 555584f

Escape strings to avoid quote problems

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import pandas as pd, numpy as np
 
3
  import os
4
  from transformers import CLIPProcessor, CLIPTextModel, CLIPModel
5
 
@@ -23,9 +24,9 @@ source = {0: '\nSource: Unsplash', 1: '\nSource: The Movie Database (TMDB)'}
23
  def get_html(url_list, height=200):
24
  html = "<div style='margin-top: 20px; max-width: 1200px; display: flex; flex-wrap: wrap; justify-content: space-evenly'>"
25
  for url, title, link in url_list:
26
- html2 = f"<img title='{title}' style='height: {height}px; margin: 5px' src='{url}'>"
27
  if len(link) > 0:
28
- html2 = f"<a href='{link}' target='_blank'>" + html2 + "</a>"
29
  html = html + html2
30
  html += "</div>"
31
  return html
@@ -48,7 +49,9 @@ description = '''
48
 
49
  **Enter your query and hit enter**
50
 
51
- *Built with OpenAI's [CLIP](https://openai.com/blog/clip/) 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/)*
 
 
52
  '''
53
 
54
  def main():
 
1
  import streamlit as st
2
  import pandas as pd, numpy as np
3
+ from html import escape
4
  import os
5
  from transformers import CLIPProcessor, CLIPTextModel, CLIPModel
6
 
 
24
  def get_html(url_list, height=200):
25
  html = "<div style='margin-top: 20px; max-width: 1200px; display: flex; flex-wrap: wrap; justify-content: space-evenly'>"
26
  for url, title, link in url_list:
27
+ html2 = f"<img title='{escape(title)}' style='height: {height}px; margin: 5px' src='{escape(url)}'>"
28
  if len(link) > 0:
29
+ html2 = f"<a href='{escape(link)}' target='_blank'>" + html2 + "</a>"
30
  html = html + html2
31
  html += "</div>"
32
  return html
 
49
 
50
  **Enter your query and hit enter**
51
 
52
+ *Built with OpenAI's [CLIP](https://openai.com/blog/clip/) 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/)
53
+
54
+ Inspired by [Unsplash Image Search](https://github.com/haltakov/natural-language-image-search) from Vladimir Haltakov and [Alph, The Sacred River](https://github.com/thoppe/alph-the-sacred-river) from Travis Hoppe*
55
  '''
56
 
57
  def main():