I Built an Offline AI Crop Disease Identifier for Smart India Hackathon
Source: Dev.to
๐ Live demo: https://dev48v.infy.uk/solve/day3-crop-disease.html
Day 3 of SolveFromZero โ pick a real hackathon brief, ship a working solution. Todayโs problem is a perennial Smart India Hackathon: 35% of Indian crop losses come from undiagnosed disease, and the village ag-extension officer canโt visit every farm.
The fix: a phone app where the farmer photographs a sick leaf, AI returns the disease + a remedy in Hindi or Marathi. Runs fully offline on a โน6,000 Android phone.
The hard constraints
Hardware โน6,000 Android phone, 2 GB RAM
Network Patchy 2G in rural areas
Model size Must fit in { const img = new Image(); img.src = URL.createObjectURL(e.target.files[0]); await img.decode();
const tensor = tf.browser.fromPixels(img) .resizeBilinear([224, 224]) .toFloat().div(255).expandDims();
const probs = await model.predict(tensor).data(); const top = probs.indexOf(Math.max(โฆprobs));
console.log(CLASSES[top], probs[top]); };
Enter fullscreen mode
Exit fullscreen mode
Stage 5 โ Remedy lookup + Hindi voice
const REMEDIES = { โtomato_late_blightโ: { treatment: โSpray 2g/L Mancozeb every 7 days for 3 weeks.โ, hindi: โเคฎเฅเคจเคเฅเคเคผเฅเคฌ 2 เคเฅเคฐเคพเคฎ/เคฒเฅเคเคฐ เคชเคพเคจเฅ เคฎเฅเค เคฎเคฟเคฒเคพเคเคฐ 7 เคฆเคฟเคจ เคฎเฅเค เคเคฟเคกเคผเคเคพเคต เคเคฐเฅเคเฅคโ }, // โฆ 38 entries };
const r = REMEDIES[CLASSES[top]];
const utter = new SpeechSynthesisUtterance(r.hindi); utter.lang = โhi-INโ; speechSynthesis.speak(utter);
Enter fullscreen mode
Exit fullscreen mode
Many farmers can't read. Voice output is the difference between "interesting demo" and "actually deployable tool."
Offline-first PWA (the critical detail)
Rural villages have spotty 2G. App must work without network after first install:
// service-worker.js self.addEventListener(โinstallโ, e => { e.waitUntil( caches.open(โcrop-v1โ).then(cache => cache.addAll([ โ/โ, โ/index.htmlโ, โ/app.jsโ, โ/model/model.jsonโ, โ/model/weights.binโ // 3.5 MB ]) ) ); });
Enter fullscreen mode
Exit fullscreen mode
After the first visit, the app + model are cached. Works in airplane mode. This is what makes the app **actually deployable**.
Try it now
3-tier page with simulated 4-leaf classifier + 9-step understanding:
**[https://dev48v.infy.uk/solve/day3-crop-disease.html](https://dev48v.infy.uk/solve/day3-crop-disease.html)**
What this unlocks
Same pipeline (small CNN + lookup table + voice) works for:
Problem
Model swap
Cattle disease ID
PlantDoc-style cattle dataset
Weed identification
DeepWeeds dataset
Soil-color โ nutrient deficiency
Custom dataset + simple classifier
Insect pest identification
IP102 dataset
The CNN + offline PWA + multilingual voice = the template for **any** rural-village AI deployment.
What's next in SolveFromZero
Day 4: **GitHub repo health scorer** (Devpost). Paste a GitHub URL โ get a health score based on stars, recent commits, issue/PR ratios.
๐ All problems: [https://dev48v.infy.uk/solvefromzero.php](https://dev48v.infy.uk/solvefromzero.php)