Spaces:
Sleeping
Sleeping
File size: 552 Bytes
5595b6e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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)
|