Spaces:
Runtime error
Runtime error
Commit
·
33b2bbe
1
Parent(s):
28dd995
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ import torch
|
|
7 |
import transformers
|
8 |
from transformers import RobertaModel, AutoTokenizer
|
9 |
|
10 |
-
#@st.cache(hash_funcs={transformers.models.roberta.tokenization_roberta_fast.RobertaTokenizerFast: hash}, suppress_st_warning=True, allow_output_mutation=True)
|
11 |
@st.cache(show_spinner=False)
|
12 |
def load():
|
13 |
text_encoder = RobertaModel.from_pretrained('SajjadAyoubi/clip-fa-text')
|
@@ -28,7 +27,7 @@ def get_html(url_list, height=224):
|
|
28 |
html += "</div>"
|
29 |
return html
|
30 |
|
31 |
-
|
32 |
def image_search(query, top_k=8):
|
33 |
with torch.no_grad():
|
34 |
text_embedding = text_encoder(**tokenizer(query, return_tensors='pt')).pooler_output
|
@@ -75,7 +74,7 @@ def main():
|
|
75 |
unsafe_allow_html=True)
|
76 |
st.sidebar.markdown(description)
|
77 |
_, c, _ = st.columns((1, 3, 1))
|
78 |
-
query = c.text_input('', value='
|
79 |
if len(query) > 0:
|
80 |
results = image_search(query)
|
81 |
st.markdown(get_html(results), unsafe_allow_html=True)
|
|
|
7 |
import transformers
|
8 |
from transformers import RobertaModel, AutoTokenizer
|
9 |
|
|
|
10 |
@st.cache(show_spinner=False)
|
11 |
def load():
|
12 |
text_encoder = RobertaModel.from_pretrained('SajjadAyoubi/clip-fa-text')
|
|
|
27 |
html += "</div>"
|
28 |
return html
|
29 |
|
30 |
+
@st.cache(show_spinner=False)
|
31 |
def image_search(query, top_k=8):
|
32 |
with torch.no_grad():
|
33 |
text_embedding = text_encoder(**tokenizer(query, return_tensors='pt')).pooler_output
|
|
|
74 |
unsafe_allow_html=True)
|
75 |
st.sidebar.markdown(description)
|
76 |
_, c, _ = st.columns((1, 3, 1))
|
77 |
+
query = c.text_input('', value='دریا')
|
78 |
if len(query) > 0:
|
79 |
results = image_search(query)
|
80 |
st.markdown(get_html(results), unsafe_allow_html=True)
|