Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,14 +52,11 @@ def detect_image(image: Image.Image):
|
|
| 52 |
high_freq_score = high_freq_artifacts(image)
|
| 53 |
|
| 54 |
# ---------- Scoring adaptif ----------
|
| 55 |
-
# Normalisasi high_freq_score ke 0-10
|
| 56 |
hf_norm = min(high_freq_score / 10, 10)
|
| 57 |
-
# Noise invers (AI biasanya noise rendah)
|
| 58 |
noise_norm = max(0, 12 - noise_score)
|
| 59 |
-
# Weighted score
|
| 60 |
weighted_score = 0.5 * hf_norm + 0.5 * noise_norm
|
| 61 |
|
| 62 |
-
#
|
| 63 |
is_ai = False
|
| 64 |
if not exif_present and weighted_score > 5 and blur_score < 150:
|
| 65 |
is_ai = True
|
|
@@ -80,7 +77,7 @@ def detect_image(image: Image.Image):
|
|
| 80 |
# ----------------------------
|
| 81 |
# GRADIO INTERFACE
|
| 82 |
# ----------------------------
|
| 83 |
-
with gr.Blocks(title="Hybrid AI Realistic Detector (
|
| 84 |
gr.Markdown("Unggah gambar, sistem akan mendeteksi apakah gambar kemungkinan besar asli atau dihasilkan AI.")
|
| 85 |
with gr.Row():
|
| 86 |
img_input = gr.Image(type="pil", label="Unggah Gambar")
|
|
|
|
| 52 |
high_freq_score = high_freq_artifacts(image)
|
| 53 |
|
| 54 |
# ---------- Scoring adaptif ----------
|
|
|
|
| 55 |
hf_norm = min(high_freq_score / 10, 10)
|
|
|
|
| 56 |
noise_norm = max(0, 12 - noise_score)
|
|
|
|
| 57 |
weighted_score = 0.5 * hf_norm + 0.5 * noise_norm
|
| 58 |
|
| 59 |
+
# Threshold tegas
|
| 60 |
is_ai = False
|
| 61 |
if not exif_present and weighted_score > 5 and blur_score < 150:
|
| 62 |
is_ai = True
|
|
|
|
| 77 |
# ----------------------------
|
| 78 |
# GRADIO INTERFACE
|
| 79 |
# ----------------------------
|
| 80 |
+
with gr.Blocks(title="Hybrid AI Realistic Detector (Jejak Digital)") as demo:
|
| 81 |
gr.Markdown("Unggah gambar, sistem akan mendeteksi apakah gambar kemungkinan besar asli atau dihasilkan AI.")
|
| 82 |
with gr.Row():
|
| 83 |
img_input = gr.Image(type="pil", label="Unggah Gambar")
|