Spaces:
Runtime error
Runtime error
Poe Dator
commited on
Commit
·
f5f9e4a
1
Parent(s):
a26874e
empty text handler added
Browse files
app.py
CHANGED
@@ -59,7 +59,7 @@ def inference(txt):
|
|
59 |
def infer_and_display_result(txt):
|
60 |
start_time = time()
|
61 |
|
62 |
-
res = inference(txt
|
63 |
res.sort(key = lambda x : - x[1])
|
64 |
|
65 |
st.markdown("###Inference results:")
|
@@ -93,14 +93,20 @@ st.write('test application for ML-2 class, YSDA-2022' )
|
|
93 |
# st.markdown("<img width=200px src='https://i.pinimg.com/736x/11/33/19/113319f0ffe91f4bb0f468914b9916da.jpg'>", unsafe_allow_html=True)
|
94 |
# st.markdown("###Predict topic by abstract.")
|
95 |
|
96 |
-
|
|
|
|
|
|
|
97 |
action = st.button('click here to infer topic')
|
98 |
|
99 |
action2 = st.button('to uppercase')
|
100 |
|
101 |
-
if action:
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
104 |
|
105 |
if action2:
|
106 |
st.write(text.upper())
|
|
|
59 |
def infer_and_display_result(txt):
|
60 |
start_time = time()
|
61 |
|
62 |
+
res = inference(txt)
|
63 |
res.sort(key = lambda x : - x[1])
|
64 |
|
65 |
st.markdown("###Inference results:")
|
|
|
93 |
# st.markdown("<img width=200px src='https://i.pinimg.com/736x/11/33/19/113319f0ffe91f4bb0f468914b9916da.jpg'>", unsafe_allow_html=True)
|
94 |
# st.markdown("###Predict topic by abstract.")
|
95 |
|
96 |
+
text1 = st.text_area("ENTER ARTICLE TITLE HERE")
|
97 |
+
text2 = st.text_area("ENTER ARTICLE ABSTRACT HERE")
|
98 |
+
text = text1 + ' ' + text2
|
99 |
+
|
100 |
action = st.button('click here to infer topic')
|
101 |
|
102 |
action2 = st.button('to uppercase')
|
103 |
|
104 |
+
if action:
|
105 |
+
if len(text) < 3:
|
106 |
+
st.write("this text is too short or empty. try again")
|
107 |
+
else:
|
108 |
+
model = build_model()
|
109 |
+
infer_and_display_result(text)
|
110 |
|
111 |
if action2:
|
112 |
st.write(text.upper())
|