Spaces:
Runtime error
Runtime error
| from transformers import pipeline | |
| from PIL import Image | |
| import gradio as gr | |
| # Load models | |
| text_model = pipeline("text-classification", model="mrm8488/bert-tiny-finetuned-fake-news-detection") | |
| image_model = pipeline("image-classification", model="prithivMLmods/Deep-Fake-Detector-v2-Model") | |
| # Text detection function | |
| def detect_text_misinformation(text): | |
| if not text.strip(): | |
| return "Please enter some text.", None | |
| result = text_model(text)[0] | |
| return f"Prediction: {result['label']}", f"Confidence: {result['score']:.2f}" | |
| # Image detection function | |
| def detect_image_deepfake(image): | |
| result = image_model(image)[0] | |
| label_map = { | |
| "LABEL_0": ("Unauthentic", "β"), | |
| "LABEL_1": ("Authentic", "β ") | |
| } | |
| label, icon = label_map.get(result['label'].upper(), (result['label'], "β")) | |
| return f"{icon} Prediction: {label}", f"Confidence: {result['score']:.2f}" | |
| # Gradio Interface | |
| text_interface = gr.Interface( | |
| fn=detect_text_misinformation, | |
| inputs=gr.Textbox(lines=3, placeholder="Enter a news statement or claim..."), | |
| outputs=["text", "text"], | |
| title="π° Misinformation Detection" | |
| ) | |
| image_interface = gr.Interface( | |
| fn=detect_image_deepfake, | |
| inputs=gr.Image(type="pil"), | |
| outputs=["text", "text"], | |
| title="πΌοΈ Deepfake Image Detection" | |
| ) | |
| demo = gr.TabbedInterface([text_interface, image_interface], ["Text Misinformation", "Image Deepfake"]) | |
| demo.launch() |