TestGradio / app.py
amelkhoadry's picture
Create app.py
4f5baeb verified
raw
history blame contribute delete
466 Bytes
from transformers import pipeline
import gradio as gr
# Load the model
sentiment_model = pipeline("sentiment-analysis")
# Define the app's logic
def analyze_sentiment(text):
result = sentiment_model(text)[0] # Get the first result
label = result['label'] # Extract label (e.g., "POSITIVE" or "NEGATIVE")
return label
# Gradio interface
interface = gr.Interface(
fn=analyze_sentiment,
inputs="text",
outputs="text",
)
interface.launch()