Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Use a valid public model | |
classifier = pipeline("text-classification", model="michiyasunaga/BERT-fake-news-detection") | |
def detect_fake_news(text): | |
result = classifier(text)[0] | |
label = result['label'] | |
score = result['score'] | |
explanation = ( | |
f"The model predicts this news is **{label}** " | |
f"with a confidence of **{score:.2f}**.\n\n" | |
"🧠 This is based on BERT fine-tuned on a fake news dataset." | |
) | |
return explanation | |
demo = gr.Interface(fn=detect_fake_news, | |
inputs=gr.Textbox(lines=10, placeholder="Paste your news article here..."), | |
outputs="markdown", | |
title="🕵️ Fake News Detector", | |
description="An NLP app that predicts whether a news article is fake or real using BERT.") | |
demo.launch() | |