Instructions to use devwinner/ocdf-maize with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use devwinner/ocdf-maize with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
# No code snippets available yet for this library.
# To use this model, check the repository files and the library's documentation.
# Want to help? PRs adding snippets are welcome at:
# https://github.com/huggingface/huggingface.jsOCDF maize leaf-disease classifier (LiteRT)
A compact EfficientNet-B0 classifier for maize leaf diseases (maize streak virus, northern leaf blight, grey leaf spot, common rust, healthy), converted to LiteRT (TensorFlow Lite) to run offline on a phone. It is part of OCDF, released with a pre-registered evaluation of how the models transfer across African image sources.
- Code, records and full documentation: github.com/DevaWinner/ocdf-cassava-maize
- Archived release (cite this): doi:10.5281/zenodo.24546864
- Companion model: devwinner/ocdf-cassava
Licence
CC BY 4.0. Free to use, including commercially, with attribution (cite the DOI below).
Files
| File | Release | Role |
|---|---|---|
maize_EfficientNetB0_s42_fp16.tflite |
Phase 1 FP16, 7.8 MiB | deployed model: use this |
comparison/maize_EfficientNetB0_s42_int8.tflite |
Phase 1 full INT8 | failed the pre-declared accuracy budget |
comparison/maize_shift_EfficientNetB0_fp16.tflite |
Phase 2 shift-augmented FP16 | frozen before the sealed test |
comparison/maize_shift_EfficientNetB0_int8_k0.tflite |
Phase 2 shift-augmented full INT8 | comparison |
comparison/maize_shift_MobileNetV2_int8.tflite |
Phase 2 MobileNetV2 full INT8 | smallest comparator |
config.json holds the class order, temperature and abstention threshold for the deployed
model. Settings for the Phase 2 files are in the
Phase 2 freeze record. SHA256SUMS lists
every file's hash; they match the frozen records in the GitHub repository.
How to use
| Input | float32 [1, 224, 224, 3], RGB, values 0–255, aspect-preserving bilinear resize with centred zero padding (tf.image.resize_with_pad) |
| Output | logits in the order M01, M02, M03, M04, M05 |
| Classes | M01 Maize streak virus · M02 Northern leaf blight · M03 Grey leaf spot · M04 Common rust · M05 Healthy maize |
| Post-processing | p = softmax(logits / 0.8557); abstain if max(p) < 0.5 |
import json, numpy as np
from huggingface_hub import hf_hub_download
from ai_edge_litert.interpreter import Interpreter # pip install ai-edge-litert
import tensorflow as tf # only for the exact resize
repo = "devwinner/ocdf-maize"
cfg = json.load(open(hf_hub_download(repo, "config.json")))
it = Interpreter(model_path=hf_hub_download(repo, cfg["model"]))
it.allocate_tensors()
img = tf.io.decode_image(tf.io.read_file("leaf.jpg"), channels=3, expand_animations=False)
x = tf.image.resize_with_pad(tf.cast(img, tf.float32), 224, 224)[None].numpy()
it.set_tensor(it.get_input_details()[0]["index"], x)
it.invoke()
logits = it.get_tensor(it.get_output_details()[0]["index"])[0]
p = np.exp(logits / cfg["temperature_T"]); p /= p.sum()
label = cfg["labels_in_output_order"][int(p.argmax())]
if p.max() < cfg["abstain_if_max_probability_below"]:
print("abstain: retake the photo or ask an expert")
else:
print(cfg["label_names"][label], round(float(p.max()), 3))
A NumPy-only version of the preprocessing (no TensorFlow) is in
src/ocdf/inference.py, and
scripts/predict.py wraps it as a command-line tool.
Training
EfficientNet-B0 pretrained on ImageNet and fine-tuned on Tanzanian maize field images and PlantVillage maize images, both CC0 (15,219 images after grouping and exclusions). Near-duplicate images were grouped so no group crosses a split. The architecture was chosen over MobileNetV2 and MobileNetV3-Small by a pre-declared rule, with seed 42 named in advance. Methods: docs/METHODS.md.
Performance (deployed file)
Macro-F1 with 95% bootstrap intervals.
| Internal test macro-F1 | 0.956 [0.935, 0.975] |
| Ghana CCMT macro-F1 (new source) | 0.809 [0.782, 0.832] |
| Ghana KaraAgro sealed test macro-F1 | 0.690 [0.673, 0.707] |
| Expected calibration error, internal → CCMT | 0.003 → 0.08 |
| Latency, 1 CPU thread: Galaxy S24 / Pixel 3 / laptop | 19.8 / 85.8 / 6.2 ms |
All results, and the per-image predictions behind them: docs/RESULTS.md.
Limitations
- Accuracy drops on images from new sources, and the model's confidence does not signal it.
- Source–class confounding: streak virus comes from one development source, and blight, leaf spot and rust only from PlantVillage laboratory images.
- Abstention does not reliably detect unfamiliar inputs such as other diseases, pests or other crops.
- Background shortcut: in one test source, healthy leaves were mostly photographed on paper. Photograph leaves where they grow.
- No Nigerian or other West African farm images with expert labels were available for training or testing.
Intended for research on offline plant-disease classification. It is not a diagnostic or advisory service and has not been validated for any farm or region. Before use in a new region, evaluate on a small set of expert-labelled local images and fine-tune on them; in this study, tens of labelled images per class recovered most of the cross-source loss.
Citation
@software{anietie_2026_ocdf,
author = {Anietie, Aniekan Winner},
title = {{OCDF}: offline cassava and maize leaf-disease classifiers with a
pre-registered cross-source evaluation},
year = {2026},
version = {1.0.0},
doi = {10.5281/zenodo.24546864},
url = {https://doi.org/10.5281/zenodo.24546864}
}
To cite whichever version is latest, use the concept DOI 10.5281/zenodo.24546863.
- Downloads last month
- -