DreamStream-1 commited on
Commit
871428f
·
verified ·
1 Parent(s): b2f8731

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -81,11 +81,11 @@ def chatbot(message, history):
81
  return history, history
82
 
83
  # Sentiment Analysis using Hugging Face model
84
- tokenizer = 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(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,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()