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

# Load model from your Hugging Face hub
model_id = "Varnikasiva/sentiment-classification-bert-mini"
classifier = pipeline("text-classification", model=model_id)

# Gradio interface
def predict(text):
    result = classifier(text)[0]
    return f"Label: {result['label']} (Score: {round(result['score'], 2)})"

gr.Interface(
    fn=predict,
    inputs=gr.Textbox(lines=3, placeholder="Type your text here..."),
    outputs="text",
    title="Sentiment Classification with BERT Mini",
    description="This model detects complex emotions like guilt, sarcasm, happiness, etc."
).launch()