DEV Community

Guri Nation
Guri Nation

Posted on • Originally published at gurdharam.com

How I Built an Offline AI Crop Disease Scanner using Flutter and TensorFlow Lite in Punjab

In rural farming regions of Punjab, 4G/5G internet connectivity is highly unreliable. If a farmer detects a crop disease, they cannot wait for cloud APIs to return a diagnosis. Latency and bandwidth costs are major barriers.

To solve this, I engineered Fasal Doctor, an offline-first agricultural mobile app built in Flutter that scans infected leaves and detects crop diseases in under 2 seconds.

Technical Architecture

  1. On-Device Inference: I fine-tuned a MobileNetV2 model on PlantVillage datasets and local Punjab crop disease patterns using PyTorch, converting it to a compact TensorFlow Lite (.tflite) format.
  2. Flutter Integration: The model runs locally on the smartphone CPU using the tflite_flutter binding. Camera frames are processed directly on-device with zero external API calls.
  3. Localized Advisory: Once diagnosed, the app fetches treatment plans and pesticides aligned with Punjab Agricultural University (PAU) guidelines from a local SQLite database.

By running everything on-device, we eliminated API costs entirely, making it 100% free and reliable for rural farming cooperatives.

To see the full case study and code breakdowns, check out my portfolio at gurdharam.com.

Top comments (0)