Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,11 +81,11 @@ def chatbot(message, history):
|
|
81 |
return history, history
|
82 |
|
83 |
# Sentiment Analysis using Hugging Face model
|
84 |
-
|
85 |
model_sentiment = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
86 |
|
87 |
def analyze_sentiment(user_input):
|
88 |
-
inputs =
|
89 |
with torch.no_grad():
|
90 |
outputs = model_sentiment(**inputs)
|
91 |
predicted_class = torch.argmax(outputs.logits, dim=1).item()
|
@@ -228,4 +228,4 @@ iface = gr.Interface(
|
|
228 |
)
|
229 |
|
230 |
# Launch the Gradio interface
|
231 |
-
iface.launch()
|
|
|
81 |
return history, history
|
82 |
|
83 |
# Sentiment Analysis using Hugging Face model
|
84 |
+
tokenizer_sentiment = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
85 |
model_sentiment = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
|
86 |
|
87 |
def analyze_sentiment(user_input):
|
88 |
+
inputs = tokenizer_sentiment(user_input, return_tensors="pt")
|
89 |
with torch.no_grad():
|
90 |
outputs = model_sentiment(**inputs)
|
91 |
predicted_class = torch.argmax(outputs.logits, dim=1).item()
|
|
|
228 |
)
|
229 |
|
230 |
# Launch the Gradio interface
|
231 |
+
iface.launch()
|