kotstantinovskii commited on
Commit
f34a41f
1 Parent(s): 87db418

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+
3
+ import streamlit as st
4
+
5
+ from torch.nn import Softmax
6
+
7
+ from model import ArxivModel, load_model
8
+ from tokenizer import get_tokenizer
9
+
10
+ from lables import num_to_classes
11
+
12
+
13
+ start_time = time.time()
14
+ model = load_model()
15
+ end_time = time.time()
16
+
17
+ print("Model:", (end_time - start_time))
18
+
19
+ start_time = time.time()
20
+ tokenizer = get_tokenizer()
21
+ end_time = time.time()
22
+
23
+ print("Tokenizer:", (end_time - start_time))
24
+
25
+ arxiv_model = ArxivModel(model, tokenizer)
26
+ softmax = Softmax(dim=1)
27
+
28
+ st.markdown("### Classification of article topics")
29
+ # st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
30
+
31
+ text = st.text_area("Write title and (optional) summary of article")
32
+ text = text.strip()
33
+
34
+ if text != "":
35
+ idxs = arxiv_model.get_idx_class(text, thr=0.95)
36
+
37
+ for idx in idxs:
38
+ st.markdown(num_to_classes[idx])
39
+ else:
40
+ st.markdown("")