KrishiLoop AgriTriage
offline model for plant disease diagnosis
2 min readupdated
KrishiLoop AgriTriage is a compact model based on the TinyViT architecture (11 million parameters), built to run directly on smartphones or in the browser. It analyzes plant leaf photos offline and identifies potential diseases across a list of 89 categories. A key feature of the model is its built-in conformal safety gate, which delivers a precise diagnosis, suggests a short-list of options, or sends the photo to an expert depending on confidence levels. The model is useful for mobile app developers and agtech projects that need fast local diagnostics without sending data to a server.
Key features
- On-device operation: The model weighs just 11.5 MB in ONNX (INT8) format and runs locally.
- 89 disease classes: Recognizes a wide range of crop diseases.
- Safety Gate: The safety algorithm reduces the risk of false positives by passing complex cases to an agronomist in time.
- Interpretability (XAI): Generates a Grad-CAM map to explain which part of the leaf the model focused on.
What you can do
- Integrate into a mobile app: Use onnxruntime-web or native ONNX Runtime to provide offline assistance to farmers.
- Create an agtech bot: Apply the model in Telegram bots for preliminary rapid analysis of field photos.
- Add a verification mechanism: Configure logic to pass uncertain images to human experts.
Example
import json, numpy as np, onnxruntime as ort
from PIL import Image
cfg = json.load(open("config.json"))
s = ort.InferenceSession("model_xai.onnx", providers=["CPUExecutionProvider"])
im = Image.open("leaf.jpg").convert("RGB")
k = cfg["resize"] / min(im.size)
im = im.resize((max(224, round(im.width * k)), max(224, round(im.height * k))), Image.Resampling.BILINEAR)
l, t = (im.width - 224) // 2, (im.height - 224) // 2
x = np.asarray(im.crop((l, t, l + 224, t + 224)), np.float32) / 255.0
out = s.run(None, {s.get_inputs()[0].name: x.transpose(2, 0, 1)[None]})
Read more
Details• Top-1 accuracy for the INT8 version is 77.5% (FP32: 77.8%) on the PlantWild test dataset.
• Architecture: TinyViT-11M, distilled from three large teacher models (DINOv2, CLIP, Perception Encoder).
• Out-of-domain performance (on PlantDoc field photos) drops in accuracy without triggering the safety gate.
• Does not process personal data: all processing happens locally on the device.










Comments