Spaces:
Sleeping
Sleeping
File size: 665 Bytes
624dc69 778a660 624dc69 778a660 624dc69 778a660 624dc69 778a660 624dc69 778a660 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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()
|