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()