AfroLogicInsect's picture
Create app.py
1e9a573 verified
raw
history blame
667 Bytes
import gradio as gr
from transformers import pipeline
## Load Pipeline
sentiment_pipeline == pipeline("sentiment-analysis",
model="AfroLogicInsect/sentiment-analysis-model")
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()