Spaces:
Sleeping
Sleeping
Memperbarui app.py dengan perubahan kecil pada kode
Browse files
app.py
CHANGED
@@ -23,15 +23,18 @@ def classify_image(img):
|
|
23 |
confidence = np.max(pred)
|
24 |
predicted_label = labels[np.argmax(pred)]
|
25 |
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
# Buat antarmuka Gradio
|
29 |
demo = gr.Interface(
|
30 |
fn=classify_image,
|
31 |
inputs=gr.Image(type="pil"),
|
32 |
outputs="text",
|
33 |
-
title="Klasifikasi
|
34 |
-
description="Upload gambar
|
35 |
)
|
36 |
|
37 |
# Launch untuk Hugging Face Spaces
|
|
|
23 |
confidence = np.max(pred)
|
24 |
predicted_label = labels[np.argmax(pred)]
|
25 |
|
26 |
+
if confidence < 0.5:
|
27 |
+
return "Tolong arahkan ke objek yang jelas agar bisa diidentifikasikan."
|
28 |
+
else:
|
29 |
+
return f"{predicted_label} (Confidence: {confidence * 100:.2f}%)"
|
30 |
|
31 |
# Buat antarmuka Gradio
|
32 |
demo = gr.Interface(
|
33 |
fn=classify_image,
|
34 |
inputs=gr.Image(type="pil"),
|
35 |
outputs="text",
|
36 |
+
title="Klasifikasi Gambar",
|
37 |
+
description="Upload gambar kami akan mengklasifikasikan dan memberikan deskripsi mengenai gambar tersebut."
|
38 |
)
|
39 |
|
40 |
# Launch untuk Hugging Face Spaces
|