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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -1,25 +1,28 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Pakai model yang masih tersedia (public)
5
- classifier = pipeline("image-classification", model="orpatashnik/StyleGAN-nada-detector")
6
 
7
  def detect_ai(image):
 
8
  results = classifier(image)
9
  label = results[0]['label']
10
  score = results[0]['score']
11
- if "real" in label.lower():
12
- return f"🌍 Foto Asli (confidence: {score:.2f})"
 
13
  else:
14
- return f"🤖 Gambar AI (confidence: {score:.2f})"
15
 
16
- # Buat interface Gradio
17
  demo = gr.Interface(
18
  fn=detect_ai,
19
  inputs=gr.Image(type="pil", label="Upload Gambar"),
20
  outputs=gr.Textbox(label="Hasil Deteksi"),
21
- title="AI Image Detector",
22
- description="Upload gambar untuk mendeteksi apakah gambar asli atau buatan AI."
 
23
  )
24
 
25
  if __name__ == "__main__":
 
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__":