Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| CLASSIFIER_MODEL_ID = "sks01dev/clickbait-classifier" | |
| classifier = pipeline( | |
| "sentiment-analysis", | |
| model=CLASSIFIER_MODEL_ID, | |
| tokenizer=CLASSIFIER_MODEL_ID, | |
| return_all_scores=True | |
| ) | |
| def predict(headline): | |
| results = classifier(headline)[0] | |
| 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="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!"], | |
| ["Government Releases New Economic Policy Report"], | |
| ] | |
| ).launch() | |