Spaces:
Runtime error
Runtime error
Commit
·
837bb92
1
Parent(s):
3069cda
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,18 @@
|
|
1 |
-
import torch
|
2 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
st.markdown("Hello!")
|
5 |
sentence = st.text_input("Please, enter your sentence. I will try to make it more positive :)")
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import torch
|
3 |
+
from transformers import BertTokenizer, BertForMaskedLM
|
4 |
+
from transformers import BertForSequenceClassification,
|
5 |
+
|
6 |
+
|
7 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
8 |
+
bert_classifier = BertForSequenceClassification.from_pretrained(
|
9 |
+
"./bert_classifier", return_dict=True).train(False)
|
10 |
|
11 |
st.markdown("Hello!")
|
12 |
sentence = st.text_input("Please, enter your sentence. I will try to make it more positive :)")
|
13 |
+
|
14 |
+
encodings = tokenizer(sentence, return_tensors='pt', padding=True)
|
15 |
+
with torch.no_grad():
|
16 |
+
logits = bert_classifier(**encodings).logits
|
17 |
+
|
18 |
+
st.markdown(logits)
|