Nikendolo commited on
Commit
c986008
1 Parent(s): b5b0ce4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -9
app.py CHANGED
@@ -68,7 +68,7 @@ def predict(text, model, human_readable=True):
68
  if not human_readable:
69
  answer.append(result[index][1])
70
  else:
71
- answer.append(labels_description[result[index][1]] + " {:.2f}%".format(100 * result[index][0]))
72
  index += 1
73
 
74
  return answer
@@ -78,17 +78,27 @@ tokenizer = DistilBertTokenizer.from_pretrained(vocab_path)
78
  model = torch.load(model_path, map_location=torch.device(device))
79
 
80
  st.markdown("### Hi! This is a service for determining the subject of an article.")
81
- st.image(img)
82
- st.markdown("### Just write the title and content in the areas below and click the \"Analyze\" button.")
 
 
 
 
 
 
 
 
83
 
84
- text1 = st.text_area("Title")
85
 
86
- text2 = st.text_area("Summary")
87
 
88
  if st.button('Analyse'):
89
  with st.spinner("Wait..."):
90
- if text1 or text2:
91
- pred = predict(text1+"\n"+text2, model.to(device))
92
- st.success("\n\n".join(pred))
 
93
  else:
94
- st.error(f"You haven't written anything.")
 
 
68
  if not human_readable:
69
  answer.append(result[index][1])
70
  else:
71
+ answer.append(labels_description[result[index][1]] + " - {:.2f}%".format(100 * result[index][0]))
72
  index += 1
73
 
74
  return answer
 
78
  model = torch.load(model_path, map_location=torch.device(device))
79
 
80
  st.markdown("### Hi! This is a service for determining the subject of an article.")
81
+ st.markdown("It can predict the following topics:\n"
82
+ "* Computer Science\n"
83
+ "* Economics\n"
84
+ "* Electrical Engineering and Systems Science\n"
85
+ "* Mathematics\n"
86
+ "* Physics\n"
87
+ "* Quantitative Biology\n"
88
+ "* Quantitative Finance\n"
89
+ "* Statistics\n")
90
+ st.markdown("#### Just write the title and abstract in the areas below and click the \"Analyze\" button.")
91
 
92
+ title = st.text_area("Title")
93
 
94
+ abstract = st.text_area("Abstract")
95
 
96
  if st.button('Analyse'):
97
  with st.spinner("Wait..."):
98
+ if not title and not abstract:
99
+ st.error(f"You haven't written anything.")
100
+ elif not title:
101
+ st.error(f"You haven't written a title.")
102
  else:
103
+ pred = predict(title+"\n"+abstract, model.to(device))
104
+ st.success("\n\n".join(pred))