Coconut leaf disease classifier

Tells which of 11 classes a coconut leaf photo shows: Bud Root Dropping, Bud Rot, Coconut Caterpillar Infestation (caterpillars), Coconut Caterpillar Infestation (leaflet damage), Gray Leaf Spot, Healthy, Leaf Rot, Stem Bleeding, Weligama Coconut Leaf Wilt β€” drying of leaflets, Weligama Coconut Leaf Wilt β€” flaccidity, Weligama Coconut Leaf Wilt β€” yellowing.

ConvNeXt-Small (convnext_small, from convnext_small.fb_in22k_ft_in1k), 224 Γ— 224 RGB, 99 MB (half precision). 99.9 % test accuracy, macro-F1 0.998, on 1,402 held-out photos. Test photos come from the same datasets the model learned from, so real field photos score lower.

Class Recall F1 Test photos
Bud Root Dropping 96.9% 0.984 64
Bud Rot 100.0% 1.000 59
Coconut Caterpillar Infestation (caterpillars) 100.0% 1.000 124
Coconut Caterpillar Infestation (leaflet damage) 100.0% 1.000 99
Gray Leaf Spot 100.0% 1.000 267
Healthy 100.0% 1.000 50
Leaf Rot 100.0% 0.995 209
Stem Bleeding 100.0% 1.000 126
Weligama Coconut Leaf Wilt β€” drying of leaflets 100.0% 1.000 135
Weligama Coconut Leaf Wilt β€” flaccidity 100.0% 1.000 134
Weligama Coconut Leaf Wilt β€” yellowing 100.0% 1.000 135

Use

import timm, torch
from PIL import Image

model = timm.create_model("hf-hub:ixrbhii/coconut-disease-convnext", pretrained=True).eval()
cfg = timm.data.resolve_data_config({}, model=model)
x = timm.data.create_transform(**cfg)(Image.open("leaf.jpg").convert("RGB")).unsqueeze(0)
p = model(x).softmax(-1)[0]
labels = model.pretrained_cfg["label_names"]
for i in p.argsort(descending=True)[:3]:
    print(labels[i], f"{100 * p[i]:.1f} %")

The training images were resized to 224 Γ— 224 without cropping; timm's transform above (resize + 224 centre crop) gives the same result for square photos. label_descriptions in config.json maps each name to the dataset's original label. Best results: one leaf filling most of the photo, in daylight and in focus. Below about 45 % confidence, ask for a better photo.

In an app: LULC Fetch (Agri β–Έ Diagnose crop disease) recognises the crop first and then runs the right disease model, with a photo-quality check and a disease map from geotagged photos.

Related

Training data and licence

Trained on public leaf-disease photo datasets, including PlantVillage (CC0) and MangoLeafBD (CC-BY-4.0). Released under CC-BY-4.0: please credit "Multi-crop disease models, IXR (agritechixr)" and the training datasets. A diagnosis supports, but doesn't replace, a local agriculture expert.

Downloads last month
38
Safetensors
Model size
49.5M params
Tensor type
F16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including ixrbhii/coconut-disease-convnext