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