Spaces:
Sleeping
Sleeping
File size: 534 Bytes
06731d3 9335ac7 06731d3 9335ac7 06731d3 39bfcde f2e33e1 9335ac7 f2e33e1 9335ac7 06731d3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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()
|