MetaQu commited on
Commit
ec2e06c
·
verified ·
1 Parent(s): c75219f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,28 +1,26 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Gunakan model publik yang valid
5
  classifier = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection")
6
 
7
  def detect_ai(image):
8
- # image dari Gradio
9
  results = classifier(image)
10
  label = results[0]['label']
11
  score = results[0]['score']
12
- # format output
13
- if "Real" in label:
14
  return f"✅ Foto Asli (confidence: {score:.2f})"
15
  else:
16
  return f"🤖 Gambar AI / Fake (confidence: {score:.2f})"
17
 
18
- # Interface Gradio
19
  demo = gr.Interface(
20
  fn=detect_ai,
21
  inputs=gr.Image(type="pil", label="Upload Gambar"),
22
  outputs=gr.Textbox(label="Hasil Deteksi"),
23
  title="AI vs Real Image Detector",
24
- description="Upload gambar untuk mengecek apakah foto asli atau buatan AI.",
25
- allow_flagging="never"
26
  )
27
 
28
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Gunakan model publik valid
5
  classifier = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection")
6
 
7
  def detect_ai(image):
 
8
  results = classifier(image)
9
  label = results[0]['label']
10
  score = results[0]['score']
11
+ # logika menentukan hasil
12
+ if "real" in label.lower():
13
  return f"✅ Foto Asli (confidence: {score:.2f})"
14
  else:
15
  return f"🤖 Gambar AI / Fake (confidence: {score:.2f})"
16
 
17
+ # Buat interface Gradio
18
  demo = gr.Interface(
19
  fn=detect_ai,
20
  inputs=gr.Image(type="pil", label="Upload Gambar"),
21
  outputs=gr.Textbox(label="Hasil Deteksi"),
22
  title="AI vs Real Image Detector",
23
+ description="Upload gambar untuk mengecek apakah gambar asli atau buatan AI."
 
24
  )
25
 
26
  if __name__ == "__main__":