Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the sentiment analysis pipeline | |
| sentiment_pipeline = pipeline("sentiment-analysis") | |
| # Corrected function | |
| def get_sentiment(input_text): | |
| result = sentiment_pipeline(input_text) # Use the pipeline, not the function itself | |
| return result[0]['label'] # Access the label correctly | |
| # Launch the web UI | |
| iface = gr.Interface( | |
| fn=get_sentiment, # Pass the function to Gradio | |
| inputs="text", | |
| outputs="text", | |
| title="My First AI App", | |
| description="Enter some text and I will tell you whether it is Positive or Negative." | |
| ) | |
| iface.launch() | |