Spaces:
Sleeping
Sleeping
Commit ·
662cc2f
1
Parent(s): 1f629fc
Create app.py
Browse files12345678910111213141516171819202122232425262728import gradio as grfrom transformers import pipeline
# Load pre-trained sentiment analysis modelsentiment_model = pipeline("sentiment-analysis")
# Function to process input sentences and return sentimentdef get_sentiment(sentence): result = sentiment_model(sentence) sentiment_label = result[0]["label"] return sentiment_label
# Create Gradio UI componentsinput_text = gr.inputs.Textbox(lines=2, placeholder="Enter your sentence here...")output_text = gr.outputs.Textbox()
# Create Gradio Interfaceiface = gr.Interface( fn=get_sentiment, inputs=input_text, outputs=output_text, title="Sentiment Analysis", description="Enter a sentence to analyze its sentiment (positive, negative, or neutral).")
# Launch Gradio Interfaceif __name__ == "__main__": iface.launch()app.pyAdded+28