MetaQu commited on
Commit
604eff9
·
verified ·
1 Parent(s): 871fbb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -1,23 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # load pipeline deteksi AI vs Real
5
- pipe = pipeline("image-classification", model="microsoft/resnet-50")
6
- # ⚠️ ganti dengan model pendeteksi AI/real sesuai yang kamu pakai
7
- # contoh lain: "microsoft/ai-image-detector"
8
 
9
  def detect_ai(image):
10
  results = pipe(image)
11
- # Ambil hasil prediksi teratas
12
  results = sorted(results, key=lambda x: x['score'], reverse=True)
13
  label = results[0]['label']
14
  confidence = results[0]['score']
15
 
16
- # Ubah jadi lebih informatif
17
- if "AI" in label or "Fake" in label:
18
- status = "Kemungkinan besar AI"
19
  else:
20
- status = "Kemungkinan besar Foto Asli"
21
 
22
  return f"{status}\n\nLabel: {label}\nConfidence: {confidence*100:.2f}%"
23
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # gunakan model deteksi AI vs Real
5
+ pipe = pipeline("image-classification", model="umm-maybe/AI-image-detector")
 
 
6
 
7
  def detect_ai(image):
8
  results = pipe(image)
 
9
  results = sorted(results, key=lambda x: x['score'], reverse=True)
10
  label = results[0]['label']
11
  confidence = results[0]['score']
12
 
13
+ if "ai" in label.lower() or "fake" in label.lower():
14
+ status = "⚠️ Kemungkinan besar AI Generated"
 
15
  else:
16
+ status = "Kemungkinan besar Foto Asli"
17
 
18
  return f"{status}\n\nLabel: {label}\nConfidence: {confidence*100:.2f}%"
19