Spaces:
Runtime error
Runtime error
benliang99
commited on
Commit
•
03251df
1
Parent(s):
cfabf1c
Updated app for finetuned model.
Browse files
app.py
CHANGED
@@ -2,8 +2,9 @@ import streamlit as st
|
|
2 |
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer, TFAutoModelForSequenceClassification
|
3 |
|
4 |
# Options for models from transformers library
|
5 |
-
MODEL_OPTS = ['default', 'bertweet-base-sentiment-analysis', 'twitter-roberta-base', 'distilRoberta-financial-sentiment']
|
6 |
-
|
|
|
7 |
|
8 |
# returns loaded model and tokenizer, if any
|
9 |
def load_model(opt):
|
@@ -11,7 +12,10 @@ def load_model(opt):
|
|
11 |
model, tokenizer = None, None
|
12 |
|
13 |
# Load the chosen sentiment analysis model from transformers
|
14 |
-
if opt ==
|
|
|
|
|
|
|
15 |
return model, tokenizer
|
16 |
elif opt == 'bertweet-base-sentiment-analysis':
|
17 |
tokenizer = AutoTokenizer.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")
|
|
|
2 |
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer, TFAutoModelForSequenceClassification
|
3 |
|
4 |
# Options for models from transformers library
|
5 |
+
MODEL_OPTS = ['finetuned', 'default', 'bertweet-base-sentiment-analysis', 'twitter-roberta-base', 'distilRoberta-financial-sentiment']
|
6 |
+
FINETUNED_OPT = MODEL_OPTS[0]
|
7 |
+
DEFAULT_OPT = MODEL_OPTS[1]
|
8 |
|
9 |
# returns loaded model and tokenizer, if any
|
10 |
def load_model(opt):
|
|
|
12 |
model, tokenizer = None, None
|
13 |
|
14 |
# Load the chosen sentiment analysis model from transformers
|
15 |
+
if opt == FINETUNED_OPT:
|
16 |
+
tokenizer = DistilBertTokenizerFast.from_pretrained('distilbert-base-uncased')
|
17 |
+
model = DistilBertForSequenceClassification.from_pretrained('saccharinedreams/finetuned-distilbert-base-uncased-for-hupd')
|
18 |
+
else if opt == DEFAULT_OPT:
|
19 |
return model, tokenizer
|
20 |
elif opt == 'bertweet-base-sentiment-analysis':
|
21 |
tokenizer = AutoTokenizer.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")
|