MetaQu commited on
Commit
2433dff
Β·
verified Β·
1 Parent(s): b735378

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -44,7 +44,7 @@ def has_camera_exif(image):
44
  return False
45
 
46
  # ----------------------------
47
- # DETEKSI HYBRID HF PRIORITAS
48
  # ----------------------------
49
  def detect_image(image):
50
  output_lines = []
@@ -58,14 +58,13 @@ def detect_image(image):
58
  result = hf_detector(image)
59
  hf_label = result[0]['label']
60
  hf_conf = result[0]['score'] * 100
61
- # tentukan HF score AI relevan
62
  if any(x in hf_label.lower() for x in ["fake", "ai", "artificial"]):
63
  hf_score = hf_conf
64
  except:
65
  hf_score = 0
66
 
67
- # Jika HF confidence tinggi β†’ langsung AI
68
- if hf_score > 60:
69
  final_result = "πŸ€– AI Detected"
70
  weighted_score = hf_score
71
  output_lines.append(f"### Hasil Deteksi:\n{final_result}")
@@ -81,7 +80,7 @@ def detect_image(image):
81
  result2 = general_model(image)
82
  general_label = result2[0]['label']
83
  general_conf = result2[0]['score'] * 100
84
- if any(x in general_label.lower() for x in ["anime","cartoon","illustration","maya"]):
85
  general_score = general_conf
86
  except:
87
  general_score = 0
@@ -97,7 +96,7 @@ def detect_image(image):
97
  local_score += 10
98
 
99
  # -------- Weighted Score (general + local) --------
100
- weighted_score = general_score*0.6 + local_score*0.4
101
 
102
  if weighted_score > 50:
103
  final_result = "πŸ€– AI Detected"
@@ -122,7 +121,7 @@ iface = gr.Interface(
122
  fn=detect_image,
123
  inputs=gr.Image(type="pil"),
124
  outputs="markdown",
125
- title="AI vs Foto Asli Detector (HF Prioritas)",
126
  description="Unggah gambar, sistem akan mendeteksi apakah gambar kemungkinan besar asli atau dihasilkan AI."
127
  )
128
 
 
44
  return False
45
 
46
  # ----------------------------
47
+ # DETEKSI HYBRID DENGAN THRESHOLD LEBIH RENDAH
48
  # ----------------------------
49
  def detect_image(image):
50
  output_lines = []
 
58
  result = hf_detector(image)
59
  hf_label = result[0]['label']
60
  hf_conf = result[0]['score'] * 100
 
61
  if any(x in hf_label.lower() for x in ["fake", "ai", "artificial"]):
62
  hf_score = hf_conf
63
  except:
64
  hf_score = 0
65
 
66
+ # Jika HF confidence > 50 β†’ langsung AI
67
+ if hf_score > 50:
68
  final_result = "πŸ€– AI Detected"
69
  weighted_score = hf_score
70
  output_lines.append(f"### Hasil Deteksi:\n{final_result}")
 
80
  result2 = general_model(image)
81
  general_label = result2[0]['label']
82
  general_conf = result2[0]['score'] * 100
83
+ if any(x in general_label.lower() for x in ["anime","cartoon","illustration","maya","3d"]):
84
  general_score = general_conf
85
  except:
86
  general_score = 0
 
96
  local_score += 10
97
 
98
  # -------- Weighted Score (general + local) --------
99
+ weighted_score = general_score*0.7 + local_score*0.3
100
 
101
  if weighted_score > 50:
102
  final_result = "πŸ€– AI Detected"
 
121
  fn=detect_image,
122
  inputs=gr.Image(type="pil"),
123
  outputs="markdown",
124
+ title="AI vs Foto Asli Detector (Versi Akurat)",
125
  description="Unggah gambar, sistem akan mendeteksi apakah gambar kemungkinan besar asli atau dihasilkan AI."
126
  )
127