Spaces:
Runtime error
Runtime error
benliang99
commited on
Commit
•
a8e4a85
1
Parent(s):
3bf18ee
Updated requirements, pipeline
Browse files- app.py +3 -3
- requirements.txt +2 -1
app.py
CHANGED
@@ -12,7 +12,7 @@ def load_model(opt):
|
|
12 |
|
13 |
# Load the chosen sentiment analysis model from transformers
|
14 |
if opt == DEFAULT_OPT:
|
15 |
-
return
|
16 |
elif opt == 'bertweet-base-sentiment-analysis':
|
17 |
tokenizer = AutoTokenizer.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")
|
18 |
model = AutoModelForSequenceClassification.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")
|
@@ -29,9 +29,9 @@ def load_model(opt):
|
|
29 |
return model, tokenizer
|
30 |
|
31 |
def sentiment_analysis(model, tokenizer):
|
32 |
-
if tokenizer:
|
33 |
return pipeline('text-classification', model=model, tokenizer=tokenizer)
|
34 |
-
else: return pipeline('text-classification'
|
35 |
|
36 |
# Title the Streamlit app 'Sentiment Analysis'
|
37 |
st.title('Sentiment Analysis')
|
|
|
12 |
|
13 |
# Load the chosen sentiment analysis model from transformers
|
14 |
if opt == DEFAULT_OPT:
|
15 |
+
return model, tokenizer
|
16 |
elif opt == 'bertweet-base-sentiment-analysis':
|
17 |
tokenizer = AutoTokenizer.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")
|
18 |
model = AutoModelForSequenceClassification.from_pretrained("finiteautomata/bertweet-base-sentiment-analysis")
|
|
|
29 |
return model, tokenizer
|
30 |
|
31 |
def sentiment_analysis(model, tokenizer):
|
32 |
+
if model and tokenizer:
|
33 |
return pipeline('text-classification', model=model, tokenizer=tokenizer)
|
34 |
+
else: return pipeline('text-classification')
|
35 |
|
36 |
# Title the Streamlit app 'Sentiment Analysis'
|
37 |
st.title('Sentiment Analysis')
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
streamlit
|
2 |
transformers
|
3 |
-
torch
|
|
|
|
1 |
streamlit
|
2 |
transformers
|
3 |
+
torch
|
4 |
+
huggingface_hub
|