Instant crop diagnosis for the 2G world.
Edge-first AI powered by INT8 MobileNetV2, built for real farms—not fast internet.
Validated across 15 crop disease classes (Tomato Early Blight, Potato Late Scab, Pepper Spot) using fine-tuned MobileNetV2 trained on 54,000+ PlantVillage images.
Most farmers rely on delayed agronomy consultations or guesswork, losing critical harvest days. Existing AI solutions demand high-end smartphones and 5G connections—luxuries absent in rural agriculture.
Sanjivani embeds expert CNN vision into offline progressive web apps. Farmers snap a photo of infected leaves and receive instant diagnosis and remedy instructions—even without internet.
How Sanjivani diagnoses crop diseases locally on budget Android phones without server roundtrips.
HTML5 Camera API captures leaf image, applies CLAHE contrast normalization, and resizes to 224x224 RGB array.
Runs INT8 quantized MobileNetV2 directly inside WebAssembly, completing forward pass in under 150ms.
Prediction result, leaf image, and GPS tag are cached into IndexedDB for offline history and review.
When 2G/3G connectivity is restored, Service Worker quietly syncs diagnostic telemetry to Flask cloud DB.
Fine-tuned MobileNetV2 covering 15+ disease classes across Tomato, Potato, and Pepper crops.
Instant local classification replaces multi-day consultation delays for critical farm decisions.
Fully functional without cellular service. Service Workers handle model caching and assets.
Minimal RAM and memory footprint (< 50MB runtime RAM) tailored for low-cost Android hardware.
Store-and-Forward architecture guarantees zero data loss during power or network outages.
Pairs disease classification with precise organic and chemical spray dosage instructions.
The core engineering challenge wasn't just accuracy—it was accessibility under extreme bandwidth constraints. Rural farmers cannot wait for 15MB cloud model payloads.
By quantizing PyTorch MobileNetV2 parameters into INT8 precision, we shrank the binary from 14.2MB to 3.4MB, enabling ONNX WebAssembly to run predictions on-device at 60 FPS.
MobileNetV2 INT8 Quantized PyTorch model (3.4 MB).
ONNX Runtime WebAssembly + OpenCV CLAHE normalization.
React PWA + Service Workers + IndexedDB Store-and-Forward.
# 1. Load Fine-Tuned PyTorch Model
model = torch.hub.load('pytorch/vision', 'mobilenet_v2')
model.classifier[1] = nn.Linear(1280, 15)
# 2. INT8 Dynamic Post-Training Quantization
quantized_model = torch.quantization.quantize_dynamic(
model, {nn.Linear, nn.Conv2d}, dtype=torch.qint8
)
# 3. Export to ONNX for WebAssembly Edge Exec
torch.onnx.export(
quantized_model,
torch.randn(1, 3, 224, 224),
"sanjivani_int8.onnx",
input_names=['leaf_tensor'],
output_names=['disease_probs']
)