File size: 456 Bytes
dc5ecd1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
from transformers import pipeline

# Load pre-trained model from Hugging Face
classifier = pipeline('sentiment-analysis')

def classify_text(text):
    result = classifier(text)[0]
    label = result['label']
    score = result['score']
    return f"{label} (confidence: {score:.2f})"

# Create the Gradio interface
iface = gr.Interface(fn=classify_text, inputs=["text"], outputs=["prediction"])

# Launch the Gradio app
iface.launch()