Upload 4 files
Browse files- README.md +12 -13
- app.py +38 -0
- daun_padi_cnn_model.h5 +3 -0
- requirements.txt +4 -0
README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Gradio
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: gradio
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: PadiCare Gradio
|
| 3 |
+
emoji: 🌾
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: gradio
|
| 7 |
+
app_file: app.py
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# PadiCare – Deteksi Penyakit Daun Padi (Gradio)
|
| 11 |
+
|
| 12 |
+
Aplikasi Gradio untuk klasifikasi penyakit daun padi berbasis CNN (.h5).
|
|
|
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
# Load model
|
| 7 |
+
model = tf.keras.models.load_model("daun_padi_cnn_model.h5")
|
| 8 |
+
|
| 9 |
+
# Label klasifikasi
|
| 10 |
+
CLASS_NAMES = [
|
| 11 |
+
"Bacterial Leaf Blight", "Leaf Blast", "Leaf Scald",
|
| 12 |
+
"Brown Spot", "Narrow Brown Spot", "Healthy"
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
# Fungsi prediksi
|
| 16 |
+
def predict_image(image: Image.Image):
|
| 17 |
+
image = image.convert("RGB").resize((150, 150))
|
| 18 |
+
img_array = np.expand_dims(np.array(image), axis=0).astype(np.float32) / 255.0
|
| 19 |
+
prediction = model.predict(img_array)[0]
|
| 20 |
+
predicted_index = int(np.argmax(prediction))
|
| 21 |
+
predicted_label = CLASS_NAMES[predicted_index]
|
| 22 |
+
confidence = float(np.max(prediction))
|
| 23 |
+
|
| 24 |
+
return {
|
| 25 |
+
label: float(f"{prob:.4f}") for label, prob in zip(CLASS_NAMES, prediction)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
# Gradio UI
|
| 29 |
+
interface = gr.Interface(
|
| 30 |
+
fn=predict_image,
|
| 31 |
+
inputs=gr.Image(type="pil"),
|
| 32 |
+
outputs=gr.Label(num_top_classes=6),
|
| 33 |
+
title="🌾 PadiCare – Deteksi Penyakit Daun Padi",
|
| 34 |
+
description="Unggah gambar daun padi, dan sistem akan mendeteksi jenis penyakitnya menggunakan model CNN."
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
# Jalankan interface
|
| 38 |
+
interface.launch()
|
daun_padi_cnn_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e23ad0922f5dd76f969dae18a211e0dc45b0e03d9b892fa5d288a5453a1d40a7
|
| 3 |
+
size 41526680
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
tensorflow==2.16.1
|
| 3 |
+
pillow
|
| 4 |
+
numpy
|