my-first-space / app.py
arnabmaj's picture
Create app.py
b4b7edb verified
raw
history blame contribute delete
318 Bytes
import gradio as gr
from transformers import pipeline
sentiment_pipeline = pipeline("sentiment-analysis")
def analyze(text):
result = sentiment_pipeline(text)[0]
return f"{result['label']} ({result['score']:.2f})"
gr.Interface(fn=analyze, inputs="text", outputs="text", title="Sentiment Analyzer").launch()