mohanty/PlantVillage
Viewer β’ Updated β’ 163k β’ 23.4k β’ 21
How to use Marconcini/leafscan-convnext-tiny with timm:
import timm
model = timm.create_model("hf-hub:Marconcini/leafscan-convnext-tiny", pretrained=True)Classifies a leaf photo into 38 crop / disease classes (14 crops) and says "Not sure" when its confidence is too low. Research / portfolio project: github.com/marconcini/leafscan β every number below comes from experiments documented there, with hypotheses written before results.
timm: convnext_tiny.fb_in22k_ft_in1k), 28M parameters, 224Γ224 input.| PlantDoc test (field, 228 photos) | PlantVillage test (lab, 10,709 photos) | |
|---|---|---|
| Accuracy | 72.4% (95% CI 66.2β78.1) | 96.6% |
| Right crop | 86.4% | β |
| Healthy vs diseased | 94.7% | β |
| Answers above the threshold | 65% of photos, 87% of them right | 94% of photos, 98.7% right |
For context: the same architecture trained on PlantVillage only reaches 99.7% on lab photos but 31% on field photos. Lab accuracy says little about real-world use.
pip install "leafscan @ git+https://github.com/marconcini/leafscan.git"
from PIL import Image
from leafscan.predictor import Predictor
predictor = Predictor("Marconcini/leafscan-convnext-tiny") # downloads config.json + model.safetensors
pred = predictor(Image.open("leaf.jpg"))
print(pred.verdict) # diagnosis, or "Not sure" below the field-calibrated threshold
print(pred.top) # top-3 (class, calibrated probability)
Files:
model.safetensors β PyTorch weights; config.json β class names, input size, temperature,
threshold (and those of the int8 model under onnx_int8).model.onnx β fp32 ONNX export, identical top-1 to PyTorch on PlantDoc test.model_int8.onnx β 32 MB, linear layers quantised to int8 (convolutions kept fp32, as ONNX
Runtime Web has no int8 convolution). Used by the in-browser demo. Same predictions as fp32
on 96.5% of PlantDoc test photos; 71.9% accuracy. Because quantisation changes some
predictions, it has its own temperature and threshold, refitted on the same field
calibration set: on PlantDoc test it answers 66% of photos, 84.7% of them right.In the browser (ONNX Runtime Web, image resizing done by the canvas instead of PIL), the demo agrees with the Python int8 predictions on 96.1% of PlantDoc test photos.
mohanty/PlantVillage.