Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,16 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
# Use a pipeline as a high-level helper
|
| 4 |
-
from transformers import pipeline
|
| 5 |
-
|
| 6 |
-
pipe = pipeline("text-classification", model="OatNapat/finetuned_yelp")
|
| 7 |
-
# Load model directly
|
| 8 |
-
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 9 |
|
|
|
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained("OatNapat/finetuned_yelp")
|
| 11 |
model = AutoModelForSequenceClassification.from_pretrained("OatNapat/finetuned_yelp")
|
| 12 |
|
|
|
|
| 13 |
nlp = pipeline("sentiment-analysis", model=model)
|
| 14 |
|
| 15 |
-
|
| 16 |
st.title("Sentiment Analysis App")
|
| 17 |
user_input = st.text_input("Enter a sentence for sentiment analysis:")
|
| 18 |
if user_input:
|
| 19 |
result = nlp(user_input)
|
| 20 |
sentiment = result[0]["label"]
|
| 21 |
-
st.write(f"Sentiment: {sentiment}")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# Load the tokenizer and model
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained("OatNapat/finetuned_yelp")
|
| 6 |
model = AutoModelForSequenceClassification.from_pretrained("OatNapat/finetuned_yelp")
|
| 7 |
|
| 8 |
+
# Create a sentiment analysis pipeline
|
| 9 |
nlp = pipeline("sentiment-analysis", model=model)
|
| 10 |
|
|
|
|
| 11 |
st.title("Sentiment Analysis App")
|
| 12 |
user_input = st.text_input("Enter a sentence for sentiment analysis:")
|
| 13 |
if user_input:
|
| 14 |
result = nlp(user_input)
|
| 15 |
sentiment = result[0]["label"]
|
| 16 |
+
st.write(f"Sentiment: {sentiment}")
|