Spaces:
Sleeping
Sleeping
import torch | |
from transformers import pipeline | |
import gradio as gr | |
# Load the sentiment analysis pipeline with a specified model | |
sentiment_analysis = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") | |
# Define a simple Gradio interface function | |
def simple_sentiment_analysis(text): | |
sentiment = sentiment_analysis(text) | |
return sentiment[0]['label'] | |
# Set up Gradio Interface | |
iface = gr.Interface( | |
fn=simple_sentiment_analysis, | |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."), | |
outputs=gr.Label(label="Sentiment"), | |
title="Sentiment Analysis", | |
description="Enter text to analyze its sentiment." | |
) | |
# Launch the interface with share=True for public access | |
iface.launch(share=True, debug=True) | |