Spaces:
Runtime error
Runtime error
Commit
•
3793f45
1
Parent(s):
bb5f62e
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ abstract = st.text_area("Enter the abstract of the article", height=350)
|
|
16 |
top_k = st.slider('How many topics from top to show?', 1, 10, 3)
|
17 |
text = title + " " + abstract
|
18 |
|
19 |
-
@st.cache(suppress_st_warning=
|
20 |
def get_model_tokenizer_linear():
|
21 |
tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-cased")
|
22 |
model = DistilBertModel.from_pretrained("distilbert-base-cased")
|
@@ -26,5 +26,8 @@ def get_model_tokenizer_linear():
|
|
26 |
my_linear.load_state_dict(torch.load(MY_LINEAR_NAME, map_location=torch.device('cpu')))
|
27 |
return {"model": model, "tokenizer": tokenizer, "my_linear": my_linear}
|
28 |
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
16 |
top_k = st.slider('How many topics from top to show?', 1, 10, 3)
|
17 |
text = title + " " + abstract
|
18 |
|
19 |
+
@st.cache(suppress_st_warning=False)
|
20 |
def get_model_tokenizer_linear():
|
21 |
tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-cased")
|
22 |
model = DistilBertModel.from_pretrained("distilbert-base-cased")
|
|
|
26 |
my_linear.load_state_dict(torch.load(MY_LINEAR_NAME, map_location=torch.device('cpu')))
|
27 |
return {"model": model, "tokenizer": tokenizer, "my_linear": my_linear}
|
28 |
|
29 |
+
if len(text) == 1:
|
30 |
+
st.markdown("Input is empty, write something!")
|
31 |
+
else:
|
32 |
+
for ms in get_answer_with_desc(text, top_k=top_k, **get_model_tokenizer_linear()):
|
33 |
+
st.markdown("#### " + ms)
|