File size: 861 Bytes
f34a41f
 
 
 
 
 
 
904bb36
f34a41f
 
 
 
 
 
 
 
 
 
904bb36
 
 
f34a41f
 
 
 
904bb36
f34a41f
904bb36
 
 
 
 
f34a41f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st

from torch.nn import Softmax

from model import ArxivModel, load_model
from tokenizer import get_tokenizer

from lables import num_to_classes, taxonomy


model = load_model()
tokenizer = get_tokenizer()

arxiv_model = ArxivModel(model, tokenizer)
softmax = Softmax(dim=1)

st.markdown("### Classification of article topics")

title_text = st.text_area("Write title of article")
summary_text = st.text_area("Write summary of article (optional)")
text = title_text.strip() + " " + summary_text.strip()
text = text.strip()

if text != "":
    idxs = arxiv_model.get_idx_class(text, thr=0.95)
    idxs = idxs[:10]

    for idx, prob in idxs:
        for tax in taxonomy:
            if num_to_classes[idx] in tax[0]:
                st.markdown("{} \t {}%".format(tax[1], round(prob*100, 1)))
                break
else:
    st.markdown("")