Spaces:
Runtime error
Runtime error
Commit
·
e059ad9
1
Parent(s):
ecab12d
Update app.py
Browse files
app.py
CHANGED
@@ -18,40 +18,49 @@ softmax = Softmax(dim=1)
|
|
18 |
st.markdown("### Classification of article topics")
|
19 |
|
20 |
col1, col2 = st.columns(2)
|
21 |
-
|
22 |
text = ""
|
23 |
-
with col1:
|
24 |
-
title_text = st.text_area("Write title of article", key='arxiv_title_input')
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
if
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
elif click_button_text and title_text.strip() != "" and summary_text.strip() != "":
|
35 |
-
text = title_text.strip() + '\t' + summary_text.strip()
|
36 |
-
elif click_button_text and title_text.strip() != "":
|
37 |
-
text = title_text.strip()
|
38 |
-
text = text.strip()
|
39 |
|
40 |
-
|
41 |
-
|
|
|
|
|
42 |
|
43 |
-
if
|
44 |
-
res = get_text_title(id_url)
|
45 |
-
if res is not None:
|
46 |
-
text = res[0].strip() + '\t' + res[1].strip()
|
47 |
-
text = text.strip()
|
48 |
-
else:
|
49 |
-
st.markdown(f'<p style="color:#FF2D00;font-size:18px">Incorrect url or id</p>', unsafe_allow_html=True)
|
50 |
text = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
if text
|
|
|
|
|
55 |
idxs = arxiv_model.get_idx_class(text, thr=0.95)
|
56 |
print(len(idxs))
|
57 |
if len(idxs) > 80:
|
|
|
18 |
st.markdown("### Classification of article topics")
|
19 |
|
20 |
col1, col2 = st.columns(2)
|
|
|
21 |
text = ""
|
|
|
|
|
22 |
|
23 |
+
frame = "text"
|
24 |
+
option = st.selectbox('Choose to write title yourself or input url/id of article',
|
25 |
+
('Write the title and summary yourself',
|
26 |
+
'Input url or id of article'))
|
27 |
|
28 |
+
if option == 'Write the title and summary yourself':
|
29 |
+
frame = 'text'
|
30 |
+
else:
|
31 |
+
frame = 'url'
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
if frame == 'text':
|
34 |
+
title_text = st.text_input("Write title of article", key='arxiv_title_input')
|
35 |
+
summary_text = st.text_area("Write summary of article (optional)", key='arxiv_sum_input')
|
36 |
+
click_button_text = st.button('Submit', key=1)
|
37 |
|
38 |
+
if click_button_text and title_text.strip() == "":
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
text = ""
|
40 |
+
if summary_text.strip() != "":
|
41 |
+
st.markdown(f'<p style="color:#FF2D00;font-size:18px">Please, input title</p>', unsafe_allow_html=True)
|
42 |
+
elif click_button_text and title_text.strip() != "" and summary_text.strip() != "":
|
43 |
+
text = title_text.strip() + '\t' + summary_text.strip()
|
44 |
+
elif click_button_text and title_text.strip() != "":
|
45 |
+
text = title_text.strip()
|
46 |
+
text = text.strip()
|
47 |
+
|
48 |
+
elif frame == 'url':
|
49 |
+
id_url = st.text_input("Write article's url or id", key='arxiv_id_input').strip()
|
50 |
+
click_button_url = st.button('Submit', key=1)
|
51 |
|
52 |
+
if click_button_url and id_url != "":
|
53 |
+
res = get_text_title(id_url)
|
54 |
+
if res is not None:
|
55 |
+
text = res[0].strip() + '\t' + res[1].strip()
|
56 |
+
text = text.strip()
|
57 |
+
else:
|
58 |
+
st.markdown(f'<p style="color:#FF2D00;font-size:18px">Incorrect url or id</p>', unsafe_allow_html=True)
|
59 |
+
text = ""
|
60 |
|
61 |
+
if text.lower() == 'i want a cake':
|
62 |
+
st.markdown("# :cake:")
|
63 |
+
elif text != "":
|
64 |
idxs = arxiv_model.get_idx_class(text, thr=0.95)
|
65 |
print(len(idxs))
|
66 |
if len(idxs) > 80:
|