FarmDoc: Empowering Nigerian Agriculture with Offline AI

The Inspiration: Bridging the Digital Divide

The spark for this initiative comes directly from recent innovations in China, where engineers deployed offline AI crop disease detectors tailored for rural farmers. These simple, camera-based tools identify plant diseases without requiring an active internet connection, running efficiently on incredibly cheap hardware. The impact has been massive, considering that most rural Chinese farmers lack access to reliable internet networks.

The Nigerian Adaptation

Nigeria stands proudly as one of Africa's largest agricultural economies, heavily reliant on staple crops like cassava, maize, and yam. However, there is a hidden variable degrading the agricultural output: crop disease.

Every year, crop diseases wipe out millions of naira for smallholder farmers who simply do not have access to professional agronomists.

We can quantify this annual economic loss, $\mathcal{L}$, using a simple sum across $n$ different crop types:

$$\mathcal{L} = \sum_{i=1}^{n} C_i \times (Y_{E,i} - Y_{A,i})$$

Where:

  • $C_i$ is the market cost per unit of crop $i$
  • $Y_{E,i}$ is the Expected Yield under healthy conditions
  • $Y_{A,i}$ is the Actual Yield after disease affliction

To minimize $\mathcal{L}$, early detection is critical. An offline crop disease detector running entirely in the mobile browser—using technologies like TensorFlow.js (requiring zero cloud compute and no dedicated GPU)—fits the Nigerian agricultural landscape perfectly.


What I'll Build: FarmDoc

FarmDoc is a Progressive Web App (PWA) designed to put an expert agronomist in the pocket of every Nigerian farmer.

Core Features:

  • 📸 Snap & Diagnose: Take or upload a photo of a diseased leaf and receive an instant diagnosis along with actionable treatment advice.
  • 📶 100% Offline Capability: Because it's built as a PWA with local service workers, the app functions flawlessly in remote fields with zero cell service.
  • 🌿 Targeted Crop Database: Specifically trained on Nigeria's top agricultural outputs:
  • Cassava
  • Maize
  • Tomato
  • Yam

  • 🗣️ Accessible Language: The interface and advice will be delivered in simple English and accessible Pidgin to ensure no farmer is left behind due to language barriers.

The Math Behind the Magic

Under the hood, FarmDoc uses a lightweight Convolutional Neural Network (CNN) executed via TensorFlow.js. When a farmer snaps a photo, the image is converted into a feature vector $\mathbf{x}$. The model outputs a probability distribution across $K$ possible crop diseases using the softmax function:

$$P(\text{Disease} = j \mid \mathbf{x}) = \frac{e^{\mathbf{w}j^\top \mathbf{x} + b_j}}{\sum{k=1}^{K} e^{\mathbf{w}_k^\top \mathbf{x} + b_k}}$$

Where $\mathbf{w}_j$ and $b_j$ represent the learned weights and biases for the $j$-th disease category. The app simply selects the disease $\hat{y}$ with the highest probability:

$$\hat{y} = \arg\max_{j \in {1, \dots, K}} P(\text{Disease} = j \mid \mathbf{x})$$

By keeping the complex mathematics hidden behind a simple, Pidgin-friendly user interface, FarmDoc will help secure yields, boost farmer incomes, and protect Nigeria's food supply.

Built With

  • 8gb
  • on
  • runs-100%-in-the-browser-using-tensorflow.js-(cpu-only
  • works
Share this project:

Updates