Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,10 +37,12 @@ def predict(title, summary, tokenizer, model):
|
|
37 |
|
38 |
@st.cache(suppress_st_warning=True)
|
39 |
def get_results(prediction, prediction_probs):
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
label_to_theme = {0: 'Computer science', 1: 'Economics', 2: 'Electrical Engineering and Systems Science', 3: 'Math',
|
46 |
4: 'Quantitative biology', 5: 'Quantitative Finance', 6: 'Statistics', 7: 'Physics'}
|
@@ -54,6 +56,7 @@ title = st.text_area(label='Title', height=100)
|
|
54 |
summary = st.text_area(label='Summary (optional)', height=250)
|
55 |
button = st.button('Run')
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
37 |
|
38 |
@st.cache(suppress_st_warning=True)
|
39 |
def get_results(prediction, prediction_probs):
|
40 |
+
for prob in prediction_probs:
|
41 |
+
prob = str("{:.2f}".format(100 * prob)) + "%"
|
42 |
+
return pd.DataFrame({
|
43 |
+
'Topic': prediction,
|
44 |
+
'Confidence': prediction_probs,
|
45 |
+
})
|
46 |
|
47 |
label_to_theme = {0: 'Computer science', 1: 'Economics', 2: 'Electrical Engineering and Systems Science', 3: 'Math',
|
48 |
4: 'Quantitative biology', 5: 'Quantitative Finance', 6: 'Statistics', 7: 'Physics'}
|
|
|
56 |
summary = st.text_area(label='Summary (optional)', height=250)
|
57 |
button = st.button('Run')
|
58 |
|
59 |
+
if button:
|
60 |
+
prediction, prediction_probs = predict(title, summary, tokenizer, model)
|
61 |
+
ans = get_results(prediction, prediction_probs)
|
62 |
+
st.write('Results: ', ans)
|