Inspiration
A farmer in Oyo, Nigeria, inspects the lower leaves of her maize and spots fungal lesions. It could be common rust, northern leaf blight, or gray leaf spot.
Rust, she can safely ignore this late in the season. Blight, she should've sprayed a week ago.
The dilemma is unforgiving:
- Guessing wrong burns money: Spraying the wrong chemical wastes up to two weeks of household income on an ineffective fungicide.
- Delaying destroys the crop: If northern leaf blight reaches the ear leaf, the leaf that fills the grain, the harvest is lost.
- The extension gap: One government extension officer serves over three thousand farms across forty miles of dirt road.
- Zero cell coverage: Out in the field, cell towers drop to zero bars.
Almost every agricultural computer vision tool built today assumes continuous 4G/5G connectivity and cloud vision APIs. When a phone has no signal in a maize field, cloud AI is dead on arrival.
Worse still is the silent failure of standard computer vision classifiers. If you point a conventional 4-class leaf classifier at a person's hand or a pair of boots, it diagnoses "gray leaf spot" with 99.6% confidence. A closed softmax cannot say "none of the above"; it is mathematically forced to distribute probability across its known classes and pick the least wrong one with artificial certainty.
We built Camleaf to solve both problems: honest, calibrated diagnostics that run entirely on the handset without a server, and a system disciplined enough to say "I don't know" when shown a non-leaf.
What It Does
Camleaf turns any smartphone browser into an edge diagnostic workstation:
Zero-Network In-Browser Inference
Users opencamleaf.farmin Chrome or Safari. The runtime and model weights are precached via a Service Worker. In the field, with the phone switched to airplane mode, a 6.2 MB MobileNetV3 model executes via ONNX Runtime WebAssembly in <60 milliseconds. The photo never touches an external server.Calibrated Out-of-Distribution Refusal
Rather than training a closed 4-class classifier, we introduced an explicit 5th negative class trained on 1,500 non-crop photographs (human hands, shoes, dirt, random foliage, tools, blank backgrounds). When an out-of-distribution image is provided, Camleaf refuses to guess, halts the diagnosis, and displays:NO DIAGNOSIS: This is not a clear single leaf. Move closer so one leaf fills the frame, or refer to an extension officer below.
Actionable Field Guidance & Knapsack Dosing
Diagnosing a pathogen is useless if the farmer cannot act safely. The guidance protocol prioritizes cultural and organic field controls first (spacing, residue removal, rotation). When chemical spraying is required, Camleaf translates abstract label rates (e.g., 2.5 kg/ha) into exact measures for a standard 16-litre knapsack sprayer tank (e.g., 40 g / approximately 2 matchbox measures).Offline WhatsApp Escalation
When a leaf is abnormal or rejected, the farmer can tap Send to Extension Officer. Camleaf formats the metadata into a structured referral ticket and saves it in local IndexedDB. The moment the handset reconnects to the network or SMS, a single tap opens WhatsApp with a pre-filled diagnostic ticket linked to local agronomy desks in Trans-Nzoia, Nigeria, and Ghana.Localized in 5 African Languages
Fully translated and accessible in English, Kiswahili, Hausa, Yorùbá, and Igbo.
How We Built It
1. Edge Machine Learning Pipeline
- Base Architecture: MobileNetV3-Small optimized for lightweight edge execution.
- Input Resolution: 224×224 RGB tensors normalized using ImageNet mean/std.
- Negative Class Regularization: Trained on a curated corpus of 1,500 non-leaf background and artifact images to establish an empirical rejection boundary.
- Export & Quantization: Exported to ONNX float32 (6.18 MB).
- Client Runtime: Executed via ONNX Runtime WebAssembly (
ort-wasm-simd.wasm) inside the browser main thread and web workers, taking advantage of SIMD hardware instructions on mobile ARM chipsets.
2. Progressive Web App & Offline Architecture
- Framework: React 18, Vite 5, React Router v6.
- Local Persistence: Dexie.js wrapping client-side IndexedDB for scan histories, custom dosage calibrations, and offline referral queues.
- Cache Lifecycle: VitePWA Workbox precaches the entire application shell, ONNX runtime binaries, and model weights on first visit. Subsequent launches load in 0.4 seconds with zero network activity.
The Measured Numbers
┌──────────────────────────────────────┬───────────────────────────────────────────┐
│ Metric │ Observed Value │
├──────────────────────────────────────┼───────────────────────────────────────────┤
│ In-Browser Inference Latency │ 33 ms (measured on mid-range handset) │
│ Model Footprint (ONNX) │ 6.18 MB │
│ WebAssembly Runtime Payload │ 13.48 MB (cached once) │
│ Outbound Data Transmitted │ 0 Bytes (100% on-device compute) │
│ Server Inference Cost │ $0.00 per scan │
│ Held-Out Dataset Accuracy │ 97.86% (n = 7,065 grouped by leaf) │
│ Non-Leaf Image Rejection Rate │ > 99.1% │
│ Crops & Disease Classes Supported │ 16 conditions across 4 crops + 1 refuse │
│ Supported African Languages │ 5 (Swahili, Hausa, Yorùbá, Igbo, English) │
└──────────────────────────────────────┴───────────────────────────────────────────┘
Challenges We Ran Into
The Closed Softmax Trap
Early prototypes exhibited the exact flaw plaguing cloud vision tools: when users held up fingers or soil, the model returned 98%+ confidence in northern leaf blight. Calibrating temperature scaling alone did not solve the issue, as logits for out-of-distribution images still peaked arbitrarily. Adding 1,500 explicit negative examples during retraining created an explicit classification basin for non-leaf imagery.WebAssembly SIMD on Mobile Handsets
Running ONNX WebAssembly on desktop Chrome was straightforward, but budget Android devices often have memory constraints or lack support for multi-threaded web workers. We tuned the execution provider to use single-threaded SIMD with preallocated memory buffers, preventing garbage-collection pauses during inference.Dosage Math vs Field Reality
Agrochemical labels state rates in kilograms per hectare, but smallholder farmers apply chemicals using 16-litre or 20-litre knapsack sprayers. Farmers do not have digital scales in the bush. We consulted agronomy extension literature to provide both grams per tank and practical volumetric equivalents (e.g., standard crown bottle-cap and matchbox measures).
Accomplishments We're Proud Of
- True Zero-Byte Transmission: Zero server bills, zero API keys, and zero privacy leakage. A farmer's photos never leave their phone.
- Knowing When to Shut Up: For agricultural extension, an AI model that refuses to guess is worth ten times more than one that hallucinates with high confidence.
- Instant Response: <60 milliseconds means no loading spinners; diagnosis feels immediate.
What We Learned
- Edge beats cloud in rural environments: In low-bandwidth geographies, client-side ML is the only reliable architecture.
- Negative classes should be mandatory: Any vision system deployed to non-experts without an explicit negative class is dangerous.
What's Next for Camleaf
- Field Calibration in Multiple African Countries: Partnering with regional agricultural extension programs to test model accuracy against live field symptoms under natural lighting.
- Crop Expansion: Training additional models for cassava (cassava mosaic virus, brown streak) and sorghum.
- Camera Bounding Box Guidance: Adding on-device real-time leaf centering to guide farmers before they take the snapshot.
Built With
- computer-vision
- dexie.js
- huggingface
- imagnet
- javascript
- onnx
- react
- tailwindcss
- transformersjs
- typescript
- vite
- webassembly
- webgpu


Log in or sign up for Devpost to join the conversation.