goalit4848 commited on
Commit
fc78d77
·
verified ·
1 Parent(s): aa272d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -34
app.py CHANGED
@@ -1,43 +1,16 @@
1
- from transformers import pipeline
2
  import gradio as gr
3
- from PIL import Image
4
- import torch
5
- import os
6
- import cv2
7
- import random
8
 
9
- # Load text classification model
10
- news_classifier = pipeline(
11
- "text-classification",
12
- model="jy46604790/Fake-News-Bert-Detect",
13
- tokenizer="jy46604790/Fake-News-Bert-Detect"
14
- )
15
 
16
  def classify_text(text):
17
  res = news_classifier(text[:512])[0]
18
- label = res["label"]
19
- score = round(res["score"] * 100, 2)
20
- return f"📰 {label} ({score}%)"
21
-
22
- def detect_fake_image(img):
23
- return "🛑 Image analysis coming soon."
24
-
25
- def analyze_video(video_file):
26
- return "🎥 Video frame analysis coming soon."
27
 
28
  with gr.Blocks() as demo:
29
- gr.Markdown("## 🔍 Fake News & Deepfake Checker (Beta)")
30
- with gr.Tab("Text"):
31
- t_input = gr.Textbox(lines=4, placeholder="Enter text or news here...")
32
- t_output = gr.Textbox()
33
- gr.Button("Check Text").click(classify_text, t_input, t_output)
34
- with gr.Tab("Image"):
35
- i_input = gr.Image(type="pil")
36
- i_output = gr.Textbox()
37
- gr.Button("Check Image").click(detect_fake_image, i_input, i_output)
38
- with gr.Tab("Video"):
39
- v_input = gr.Video()
40
- v_output = gr.Textbox()
41
- gr.Button("Check Video").click(analyze_video, v_input, v_output)
42
 
43
  demo.launch()
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
 
 
 
 
3
 
4
+ news_classifier = pipeline("text-classification", model="typeform/distilbert-base-uncased-mnli")
 
 
 
 
 
5
 
6
  def classify_text(text):
7
  res = news_classifier(text[:512])[0]
8
+ return f"{res['label']} ({round(res['score'] * 100, 2)}%)"
 
 
 
 
 
 
 
 
9
 
10
  with gr.Blocks() as demo:
11
+ gr.Markdown("## 🧠 Fake News Detector (Text Only)")
12
+ text_input = gr.Textbox(label="Paste your news here")
13
+ output = gr.Textbox(label="Prediction")
14
+ gr.Button("Check News").click(classify_text, text_input, output)
 
 
 
 
 
 
 
 
 
15
 
16
  demo.launch()