Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# β Use a working fake news detection model | |
classifier = pipeline("text-classification", model="mrm8488/bert-tiny-finetuned-fake-news-detection") | |
# π‘ Function to classify news | |
def detect_fake_news(text): | |
result = classifier(text)[0] | |
label = result["label"] | |
score = result["score"] | |
explanation = "π’ This looks like real news." if label == "REAL" else "π΄ This might be fake news." | |
return f"Prediction: {label}\nConfidence: {score:.2f}\n{explanation}" | |
# ποΈ Gradio UI | |
iface = gr.Interface( | |
fn=detect_fake_news, | |
inputs=gr.Textbox(lines=10, placeholder="Paste your news article here..."), | |
outputs="text", | |
title="π° Fake News Detector", | |
description="Detect whether a news article is real or fake using a fine-tuned BERT model." | |
) | |
iface.launch() |