Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
pipe = pipeline("image-classification", model="
|
| 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 |
-
|
| 17 |
-
|
| 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 |
|