mbabanov commited on
Commit
d98e05f
1 Parent(s): c5da81d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -1,13 +1,27 @@
1
  import streamlit as st
 
 
2
 
3
- st.markdown("### Hello, world!")
4
- st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
5
 
6
- from transformers import pipeline
 
 
7
 
8
- def process(text):
9
- return text[::-1]
10
 
11
- text = st.text_area("TEXT HERE")
 
 
 
 
 
 
 
 
 
12
 
13
- st.markdown(f"{process(text)}")
 
 
 
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)}")