Sanjayraju30's picture
Update app.py
d4acf75 verified
raw
history blame contribute delete
853 Bytes
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()