Instructions to use wisamWR/Tomato_Leaf_Diseases-CNN_Comparative_Analysis with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use wisamWR/Tomato_Leaf_Diseases-CNN_Comparative_Analysis with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://wisamWR/Tomato_Leaf_Diseases-CNN_Comparative_Analysis") - Notebooks
- Google Colab
- Kaggle
Tomato Leaf Disease Classifier (EfficientNetV2B0)
Model klasifikasi gambar buat deteksi penyakit daun tomat. Base: EfficientNetV2B0 (transfer learning, ImageNet weights), head custom (GlobalAveragePooling β Dense 128 β Dropout 0.5 β Softmax 10 kelas). Dipilih sbg model terbaik dari perbandingan 14 arsitektur CNN (VGG, ResNet, DenseNet, MobileNet, EfficientNet, Xception, NASNet).
Model Details
- Architecture: EfficientNetV2B0 (frozen base, ImageNet pretrained) + custom classification head
- Input: RGB image, resize ke 224x224, preprocess pakai
tf.keras.applications.efficientnet_v2.preprocess_input - Output: 10 kelas (softmax)
- Framework: TensorFlow / Keras (
.h5format) - Training: 10 epoch, batch size 64, Adam optimizer, mixed precision, augmentation (flip, brightness, contrast, saturation, rotation), oversampling kelas minoritas + class weights buat handle imbalance
Classes
Tomato_Bacterial_spot
Tomato_Early_blight
Tomato_Late_blight
Tomato_Leaf_Mold
Tomato_Septoria_leaf_spot
Tomato_Spider_mites_Two_spotted_spider_mite
Tomato_Target_Spot
Tomato_Tomato_Yellow_Leaf_Curl_Virus
Tomato_Tomato_mosaic_virus
Tomato_Healthy
Performance (validation set)
| Metric | Score |
|---|---|
| Accuracy | 97.38% |
| Precision | 0.9702 |
| Recall | 0.9631 |
| F1-Score | 0.9664 |
Best di antara 14 model yang dibandingkan (VGG16/19, ResNet50/101/152/50V2, EfficientNet B0/B3/V2B0/V2B3/V2S, DenseNet121/169/201, Xception, NASNetMobile/Large, MobileNetV3 Small/Large).
Dataset
PlantVillage Tomato Leaf Dataset β gambar daun tomat terbagi ke 10 kelas (9 penyakit + sehat). Split stratified 80/20 train-validation, oversampling kelas minoritas di set training.
Usage
import tensorflow as tf
import numpy as np
from PIL import Image
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(repo_id="<username>/<repo-name>", filename="EfficientNetV2B0_best.h5")
model = tf.keras.models.load_model(model_path)
CLASS_NAMES = [
"Tomato_Bacterial_spot", "Tomato_Early_blight", "Tomato_Late_blight",
"Tomato_Leaf_Mold", "Tomato_Septoria_leaf_spot",
"Tomato_Spider_mites_Two_spotted_spider_mite", "Tomato_Target_Spot",
"Tomato_Tomato_Yellow_Leaf_Curl_Virus", "Tomato_Tomato_mosaic_virus", "Tomato_Healthy",
]
image = Image.open("daun_tomat.jpg").convert("RGB").resize((224, 224))
arr = np.expand_dims(tf.keras.applications.efficientnet_v2.preprocess_input(np.array(image, dtype=np.float32)), axis=0)
preds = model.predict(arr)[0]
print(CLASS_NAMES[int(np.argmax(preds))], float(np.max(preds)))
Demo Streamlit ada di app.py.
Limitations
- Dilatih cuma 10 epoch dgn base model frozen β belum fine-tuned penuh.
- Performa bisa turun di gambar dgn kondisi pencahayaan/background beda dari dataset PlantVillage (yg umumnya background bersih studio).
- Bukan pengganti diagnosis ahli pertanian/agronomis.
Training Notebook
Detail eksperimen, EDA, dan perbandingan semua arsitektur ada di tomato-leaf-diseases-cnn-comparative-analysis.ipynb.
- Downloads last month
- -