'mint autosave'
Browse files- .gitignore +2 -0
- app.py +11 -4
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
results/**
|
2 |
+
data/**
|
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st #Web App
|
2 |
from transformers import pipeline
|
3 |
-
from transformers import AutoTokenizer,
|
4 |
|
5 |
|
6 |
#title
|
@@ -12,20 +12,27 @@ def analyze(input, model):
|
|
12 |
|
13 |
|
14 |
# load my fine-tuned model
|
15 |
-
fine_tuned =
|
16 |
|
17 |
|
18 |
#text insert
|
19 |
-
input = st.text_area("insert text to be analyzed", value="Nice to see you today.",
|
|
|
|
|
|
|
20 |
option = st.selectbox(
|
21 |
'Choose a transformer model:',
|
22 |
('Default', 'Fine-Tuned' , 'Custom'))
|
23 |
|
24 |
|
25 |
if option == 'Fine-Tuned':
|
26 |
-
model =
|
27 |
tokenizer = AutoTokenizer.from_pretrained(fine_tuned)
|
28 |
classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
|
|
|
|
|
|
|
|
|
29 |
else:
|
30 |
classifier = pipeline('sentiment-analysis')
|
31 |
|
|
|
1 |
import streamlit as st #Web App
|
2 |
from transformers import pipeline
|
3 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
4 |
|
5 |
|
6 |
#title
|
|
|
12 |
|
13 |
|
14 |
# load my fine-tuned model
|
15 |
+
fine_tuned = "fine_tuned/______"
|
16 |
|
17 |
|
18 |
#text insert
|
19 |
+
input = st.text_area("insert text to be analyzed", value="Nice to see you today.",
|
20 |
+
height=None, max_chars=None, key=None, help=None, on_change=None,
|
21 |
+
args=None, kwargs=None, placeholder=None, disabled=False,
|
22 |
+
label_visibility="visible")
|
23 |
option = st.selectbox(
|
24 |
'Choose a transformer model:',
|
25 |
('Default', 'Fine-Tuned' , 'Custom'))
|
26 |
|
27 |
|
28 |
if option == 'Fine-Tuned':
|
29 |
+
model = AutoModelForSequenceClassification.from_pretrained(fine_tuned)
|
30 |
tokenizer = AutoTokenizer.from_pretrained(fine_tuned)
|
31 |
classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
|
32 |
+
elif option == 'Roberta':
|
33 |
+
model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
34 |
+
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
35 |
+
classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
|
36 |
else:
|
37 |
classifier = pipeline('sentiment-analysis')
|
38 |
|