Dhana2403's picture
Update app.py
f2e33e1 verified
raw
history blame contribute delete
534 Bytes
from transformers import pipeline
import gradio as gr
# Load the pre-trained sentiment analysis model
sentiment_analyzer = pipeline('sentiment-analysis')
# Define the function for sentiment analysis
def analyze_sentiment(text):
result = sentiment_analyzer(text)
# Only return the sentiment label
return result[0]['label']
# Set up the Gradio interface (use text output for easier debugging)
interface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")
# Launch the Gradio interface
interface.launch()