AfroLogicInsect's picture
Update app.py
e7da2c8 verified
raw
history blame
669 Bytes
import gradio as gr
from transformers import pipeline
## Load Pipeline
sentiment_pipeline = pipeline("sentiment-analysis",
model="AfroLogicInsect/sentiment-analysis-model_v2")
def predict_sentiment(text):
if not text.strip():
return "Please enter some text", 0.0
result = sentiment_pipeline(text)[0]
label = "😊 Positive" if result['label'] == 'LABEL_1' else "😞 Negative"
return label, round(result['score'], 3)
iface = gr.Interface(
fn = predict_sentiment,
inputs=gr.Textbox(label="Enter text"),
outputs=[gr.Text(label="Sentiment"),
gr.Number(label="Confidence")]
)
iface.launch()