WhoLetMeCook commited on
Commit
40223c1
·
verified ·
1 Parent(s): 99b4a75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
  import torch
4
 
@@ -15,12 +15,13 @@ def predict_emotion(text):
15
  prediction = torch.argmax(outputs.logits, dim=-1).item()
16
  return "Positive Emotion" if prediction == 1 else "Negative Emotion"
17
 
18
- # Create the Gradio interface
19
- iface = gr.Interface(fn=predict_emotion,
20
- inputs="text",
21
- outputs="text",
22
- title="ChefBERT Emotion Classifier",
23
- description="Enter a sentence and ChefBERT will predict whether the emotion is positive (1) or negative (0).")
24
 
25
- # Launch the interface
26
- iface.launch()
 
 
 
 
 
1
+ import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
  import torch
4
 
 
15
  prediction = torch.argmax(outputs.logits, dim=-1).item()
16
  return "Positive Emotion" if prediction == 1 else "Negative Emotion"
17
 
18
+ # Streamlit app layout
19
+ st.title("Emotion Classifier")
20
+ st.write("Enter a sentence and ChefBERT will predict whether the emotion is positive (1) or negative (0).")
 
 
 
21
 
22
+ # Input box
23
+ user_input = st.text_input("Input Sentence", "")
24
+
25
+ if user_input:
26
+ result = predict_emotion(user_input)
27
+ st.write("Prediction: ", result)