lokeshnaik33339's picture
Create app.py
5595b6e verified
Raw History Blame Contribute Delete
552 Bytes
import gradio as gr
from transformers import pipeline
# Load the sentiment analysis pipeline
nlp = pipeline("sentiment-analysis")
# Define the function for sentiment analysis
def analyze_sentiment(text):
result = nlp(text)
return result
# Create the Gradio interface
iface = gr.Interface(
fn=analyze_sentiment,
inputs="text",
outputs="text",
title="Sentiment Analysis",
description="Enter a sentence to analyze its sentiment."
)
# Launch the Gradio app
if __name__ == "__main__":
iface.launch(debug=True,share=True)