Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,27 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
3 |
-
st.markdown("###
|
4 |
-
st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
|
5 |
|
6 |
-
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
return text[::-1]
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
st.
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import torch
|
3 |
+
import transformers
|
4 |
|
5 |
+
st.markdown("### Articles classificator.")
|
6 |
+
# st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
|
7 |
|
8 |
+
@st.cache_data
|
9 |
+
def LoadModel():
|
10 |
+
return torch.load('model.pt'), AutoTokenizer.from_pretrained('bert-base-uncased')()
|
11 |
|
12 |
+
model, tokenizer = LoadModel()
|
|
|
13 |
|
14 |
+
def process(title, summary):
|
15 |
+
text = title + summary
|
16 |
+
model.eval()
|
17 |
+
lines = [text]
|
18 |
+
X = tokenizer(lines, padding=True, truncation=True, return_tensors="pt")
|
19 |
+
out = model(X)
|
20 |
+
probs = torch.exp(out[0])
|
21 |
+
return probs
|
22 |
+
|
23 |
+
title = st.text_area("Title")
|
24 |
|
25 |
+
summary = st.text_area("Summary")
|
26 |
+
|
27 |
+
st.markdown(f"{process(title, summary)}")
|