strangekitten commited on
Commit
362dc22
1 Parent(s): 7b9ec5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -1,8 +1,25 @@
1
  import streamlit as st
2
 
 
 
 
 
 
 
 
 
3
  st.markdown("## Classifying articles on computer science!")
4
  st.markdown("<img width=400px src='https://img.freepik.com/free-photo/young-pretty-student-overwhelmed-with-books_272645-183.jpg?size=626&ext=jpg'>", unsafe_allow_html=True)
5
 
6
-
7
  title = st.text_area("Enter the title of the article")
8
- abstract = st.text_area("Enter the abstract of the article")
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ from transformers import DistilBertTokenizer, DistilBertModel
4
+ import torch
5
+ import torch.nn as nn
6
+
7
+ from .utils import get_answer_with_desc
8
+
9
+ MY_LINEAR_NAME = "my_linear_logits_3"
10
+
11
  st.markdown("## Classifying articles on computer science!")
12
  st.markdown("<img width=400px src='https://img.freepik.com/free-photo/young-pretty-student-overwhelmed-with-books_272645-183.jpg?size=626&ext=jpg'>", unsafe_allow_html=True)
13
 
 
14
  title = st.text_area("Enter the title of the article")
15
+ abstract = st.text_area("Enter the abstract of the article")
16
+ text = title + " " + abstract
17
+
18
+ tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-cased")
19
+ model = DistilBertModel.from_pretrained("distilbert-base-cased")
20
+
21
+ n_classes = 40
22
+ my_linear = nn.Linear(in_features=768, out_features=n_classes, bias=True)
23
+ my_linear.load_state_dict(torch.load(MY_LINEAR_NAME))
24
+
25
+ st.markdown(get_answer_with_desc(text, model, tokenizer, my_linear))