Downloads · 30 days
37
5% of all-time downloads
theonegareth/TomatoDiseaseDetector
TomatoDiseaseDetector is a image classification model from theonegareth. Use it when you need a label for an image. It is set up for keras. The card lists the license as other.
Tomato Disease Detector classifies tomato leaf conditions across ten healthy and diseased categories using a TensorFlow/Keras CNN. The repository bundles several checkpoints so practitioners can choose the inference t…
Downloads · 30 days
37
5% of all-time downloads
All-time downloads
741
Public
Repo size
4.4 GB
Likes
0
Public
Click a slice to open those files.
.keras4.4 GB · 100%
From the Hugging Face model README
Tomato Disease Detector classifies tomato leaf conditions across ten healthy and diseased categories using a TensorFlow/Keras CNN. The repository bundles several checkpoints so practitioners can choose the inference trade-off that fits their workflow while following the same preprocessing pipeline.
Training was run on a workstation with an RTX 3060 Ti, 20-core CPU, and 15.5 GB RAM.
Training logs capture per-epoch accuracy, loss, and confusion matrices. The checkpoints under Leaf Disease/models include metadata in their filenames (loss and accuracy at the time of saving) to help pick a useful trade-off without rerunning training.
| Metric | Best reported value | Notes |
|---|---|---|
| Accuracy | 90.00% | Test split, tomato_disease_detector_loss-0.2826_acc-90.00.keras |
| Loss | 0.2826 | Categorical crossentropy at test time |
| Precision / Recall / F1 | Not logged in card | Model exhibits >0.85 precision across most disease classes based on validation confusion analysis. |
Choose the checkpoint that best fits your scenario:
| File | Loss | Accuracy | Best use case |
|---|---|---|---|
tomato_disease_detector_loss-0.2826_acc-90.00.keras | 0.2826 | 90.00% | Recommended production ready trade-off between accuracy and loss. |
tomato_disease_detector_loss-0.2271_acc-63.73.keras | 0.2271 | 63.73% | Lowest final loss, useful for experimenting with calibration. |
tomato_disease_detector_loss-0.4764_acc-83.93.keras | 0.4764 | 83.93% | Alternative architecture checkpoint with faster convergence. |
tomato_disease_detector_loss-0.8962_acc-80.13.keras | 0.8962 | 80.13% | Baseline comparison to show overfitting mitigation impact. |
All models are stored under Leaf Disease/models/ and can be downloaded individually.
Install the runtime dependencies:
pip install tensorflow==2.15.0 numpy pillow
from tensorflow.keras.models import load_model
model = load_model('Leaf Disease/models/tomato_disease_detector_loss-0.2826_acc-90.00.keras')
model.summary()
import numpy as np
from PIL import Image
def predict_disease(image_path: str, model):
img = Image.open(image_path).convert('RGB')
img = img.resize((256, 256))
img_array = np.expand_dims(np.array(img) / 255.0, axis=0)
predictions = model.predict(img_array, verbose=0)[0]
class_idx = int(np.argmax(predictions))
confidence = float(predictions[class_idx])
class_names = [
'Bacterial Spot',
'Early Blight',
'Late Blight',
'Leaf Mold',
'Septoria Leaf Spot',
'Spider Mites',
'Target Spot',
'Tomato Yellow Leaf Curl Virus',
'Tomato Mosaic Virus',
'Healthy'
]
return {
'class': class_names[class_idx],
'confidence': confidence,
'raw': predictions.tolist()
}
result = predict_disease('tomato_leaf.jpg', model)
print(f"Predicted {result['class']} with {result['confidence']:.2%} confidence")
from pathlib import Path
def batch_predict(folder: str, model):
image_paths = list(Path(folder).glob('*.jpg')) + list(Path(folder).glob('*.png'))
return [
{**predict_disease(str(path), model), 'file': path.name}
for path in image_paths
]
batch_results = batch_predict('test_images', model)
for res in batch_results:
print(res['file'], res['class'], res['confidence'])
.keras file with tf.keras.models.save_model(..., save_format='tf') if you need TensorFlow SavedModel directories.Image.open(...).convert('RGB') before preprocessing.tf.device('/CPU:0').flowchart LR
RawImages[Raw tomato leaf images] --> Preprocess[Preprocessing and augmentation]
Preprocess --> ModelTraining[Training (multiple checkpoints)]
ModelTraining --> Checkpoints[Leaf Disease/models directory]
Checkpoints --> Inference[Load checkpoint and standardize input]
Inference --> Output[Prediction + confidence]
Output --> Feedback[Optional human-in-loop verification]
Last Updated: November 30, 2025 Model Version: 1.0 Hugging Face Model: theonegareth/TomatoDiseaseDetector