Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -29,10 +29,10 @@ def get_predictions(logits, indexes):
|
|
29 |
return ind, probs
|
30 |
|
31 |
|
32 |
-
def return_pred_name(
|
33 |
out = []
|
34 |
for i in ind:
|
35 |
-
out.append(
|
36 |
return out
|
37 |
|
38 |
|
@@ -49,7 +49,7 @@ def predict(title, summary, model, tokenizer):
|
|
49 |
prediction = []
|
50 |
prediction_probs = []
|
51 |
while sum_probs < 0.95:
|
52 |
-
prediction.append(
|
53 |
prediction_probs.append(str("{:.2f}".format(100 * probs[classes[ind]])) + "%")
|
54 |
sum_probs += probs[classes[ind]]
|
55 |
ind += 1
|
@@ -61,28 +61,27 @@ def get_results(prediction, prediction_probs):
|
|
61 |
frame = pd.DataFrame({'Category': prediction, 'Confidence': prediction_probs})
|
62 |
frame.index = np.arange(1, len(frame) + 1)
|
63 |
return frame
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
0: 'adap-org'}
|
85 |
-
|
86 |
|
87 |
|
88 |
st.title("Find out the topic of the article without reading!")
|
|
|
29 |
return ind, probs
|
30 |
|
31 |
|
32 |
+
def return_pred_name(names, ind):
|
33 |
out = []
|
34 |
for i in ind:
|
35 |
+
out.append(names[i])
|
36 |
return out
|
37 |
|
38 |
|
|
|
49 |
prediction = []
|
50 |
prediction_probs = []
|
51 |
while sum_probs < 0.95:
|
52 |
+
prediction.append(names[classes[ind]])
|
53 |
prediction_probs.append(str("{:.2f}".format(100 * probs[classes[ind]])) + "%")
|
54 |
sum_probs += probs[classes[ind]]
|
55 |
ind += 1
|
|
|
61 |
frame = pd.DataFrame({'Category': prediction, 'Confidence': prediction_probs})
|
62 |
frame.index = np.arange(1, len(frame) + 1)
|
63 |
return frame
|
64 |
+
|
65 |
|
66 |
+
names = {3: 'cs',
|
67 |
+
18: 'stat',
|
68 |
+
10: 'math',
|
69 |
+
14: 'physics',
|
70 |
+
15: 'q-bio',
|
71 |
+
0: 'astro-ph',
|
72 |
+
2: 'cond-mat',
|
73 |
+
17: 'quant-ph',
|
74 |
+
5: 'eess',
|
75 |
+
1: 'cmp-lg',
|
76 |
+
8: 'hep-ph',
|
77 |
+
6: 'gr-qc',
|
78 |
+
9: 'hep-th',
|
79 |
+
12: 'nlin',
|
80 |
+
4: 'econ'
|
81 |
+
16: 'q-fin',
|
82 |
+
7: 'hep-ex',
|
83 |
+
11: 'math-ph',
|
84 |
+
13: 'nucl-th'}
|
|
|
|
|
85 |
|
86 |
|
87 |
st.title("Find out the topic of the article without reading!")
|