File size: 769 Bytes
203873a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 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)