Spaces:
Sleeping
Sleeping
File size: 853 Bytes
b7302da 2b5ac81 b7302da 174d12c b7302da e88771b 2b5ac81 174d12c b7302da 2b5ac81 174d12c 2b5ac81 b7302da 174d12c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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() |