sks01dev's picture
Production Deploy: Final minimal app and configuration.
bf7fdad
raw
history blame
1.11 kB
import gradio as gr
from transformers import pipeline
CLASSIFIER_MODEL_ID = "sks01dev/clickbait-classifier"
# Load model assets directly from the Hub
classifier = pipeline(
"sentiment-analysis",
model=CLASSIFIER_MODEL_ID,
tokenizer=CLASSIFIER_MODEL_ID,
return_all_scores=True
)
def predict(headline):
results = classifier(headline)[0]
# Format output for clear confidence display
formatted_output = {
"NOT CLICKBAIT (0)": results[0]['score'],
"CLICKBAIT (1)": results[1]['score']
}
return formatted_output
# Gradio Interface Setup
gr.Interface(
fn=predict,
inputs=gr.Textbox(lines=2, label="Enter News Headline"),
outputs=gr.Label(num_top_classes=2, title="Prediction Confidence"),
title="World-Class Clickbait Predictor",
description="DeBERTa-v3-small model deployed for high-confidence headline analysis.",
examples=[
["10 Ways To Instantly Improve Your Mood"],
["You Won't Believe What Happened When We Tested This!"],
["You Won't Believe What Happened When We Tested This!"],
]
).launch()