← 목록

KisanConnect Innohacks 4.0

devto 2026-10-11 원문 보기 ↗


This is a submission for the MLH x DEV Writing Challenge

What I Built

India has over 100 million farming households, and most of them make their biggest decisions on guesswork: what to plant this season, how much fertilizer to buy, whether those brown spots on a leaf are an emergency. The advice that exists is generic. It ignores the farmer's soil, climate and nutrient levels, and it rarely speaks the farmer's language.

KisanConnect is our attempt at fixing that. Built by Team Code Hunters at Innohacks 4.0 (KIET, Ghaziabad), it is one Flask app where a farmer enters soil numbers or uploads a leaf photo and gets a clear decision back:

Standing on the shoulders of KrishiDisha

KisanConnect is built on the open-source KrishiDisha project by Shivpratap Singh Panwar, Abhishek Chourasia and Goutam Mandloi (IEEE ICoEIT 2025), and it carries the same PolyForm Noncommercial licence. Our work was the rebrand, environment setup and fixes (for example, the yield trainer now uses a dense one-hot encoder so it trains on current scikit-learn), integration, the Gemini-powered assistant setup, deployment on Render and the demo. The upstream authors' reported results are theirs, and our README says so.

Demo

The app runs on Render's free tier, so if it has been idle, the first load can take up to a minute while the service wakes up.

How It Works

Farmer / Admin
      │
  Flask app (blueprints: main · auth · farmer · marketplace · admin · chat · api)
      │
  Services: ml · disease · knowledge · tools · llm · fallback_bot · weather · market · reports
      │
  ├── models/   crop · fertilizer · yield · disease
  ├── data/     CSV datasets + knowledge JSON (schemes, products, guides, calendar, pests, MSP)
  ├── APIs      Open-Meteo · data.gov.in Agmarknet · Gemini API
  └── DB        SQLite (default) or MySQL

1. Crop recommendation, with a seatbelt

A Random Forest takes N, P, K, temperature, humidity, pH and rainfall and returns the top-3 crops with predict_proba. Before predicting, we check whether the inputs fall inside the training range (1st to 99th percentile). If they don't, the farmer gets a caution warning instead of a confident answer about conditions the model has never seen.

2. Fertilizer: rule first, model second

This is the design decision I like most. The dataset has only 99 rows, so a high Random Forest score there is memorisation, not skill. So the recommendation comes from agronomy rules:

  1. Take the crop's nutrient requirement per hectare.
  2. Adjust it by ±25% depending on whether the soil test reads low or high.
  3. Compute the N, P₂O₅ and K₂O deficit.
  4. Rank the fertilizer catalogue by cosine similarity between its NPK ratio and the deficit.
  5. Hand the result to the dose calculator (kg, bags, split schedule).

The classifier still runs, but only as a labelled model_hint. It is shown, never obeyed.

3. Yield prediction without leakage

Our trainer never receives Production as an input, because production divided by area is the target, and including it would leak the answer. Missing fertilizer and pesticide values are filled from the State × Crop median, falling back to crop, then global. On a time split (train up to 2016, test 2017-2020), no model we tried beat the 5-year Crop × State median (MAE 1.10 t/ha, R² 0.66). So the baseline ships, together with a 10th-90th percentile interval so farmers see a range, not false precision.

4. Disease detection that can say "I'm not sure"

leaf photo → preprocess → is it a leaf? → classifier → confident enough? → result
                              │ no                          │ no
                              ▼                             ▼
                      reject, clear message        show as uncertain,
                                                   ask for a clearer photo

A plant check rejects non-leaf images. A confidence threshold turns shaky predictions into "uncertain" instead of a wrong diagnosis. A confident result returns the condition, prevention steps, matching marketplace products and a downloadable PDF report. The original KrishiDisha field model reports 95.6% top-1 (v1, 1,650 field photos) and 94.3% (v2, 2,828 photos). Those weights are not distributed, so this deployment uses a public MobileNetV2 demo model (38 classes), and we clearly separate the two in the README.

5. A Gemini-powered assistant with a built-in backup

The assistant's brain is selected by one setting, LLM_PROVIDER. For KisanConnect we connected Google's Gemini API through its OpenAI-compatible endpoint, which means swapping models is a configuration change, not a code change.

The important part is what sits around the model:

Farmers can type in Hindi or Hinglish and ask things like "mere khet me urea kitna daalu?", and the assistant routes the question to the dose calculator instead of improvising a number.

6. Built to be extended

Everything above is also exposed as a JSON API under /api/v1/..., so an SMS or WhatsApp gateway can reach farmers without smartphones. The test suite runs fully offline with a stub disease model and an in-memory database, so pytest works on any laptop.

What I Learned

Partner Technologies

Hackathon Experience

Innohacks 4.0 at KIET was Minecraft-themed ("We Learn, We Teach, We Conquer"), and our track was AI in Agriculture. Our team of four (Ujjwal Sharma, Aanya Malik, Nishita and Aastha) spent the event turning an open-source research project into something a farmer could actually use, reading model cards at odd hours and arguing about which number deserved to be on the slide.

What's Next

If you have built for low-literacy or low-connectivity users, what would you add first? I'd love to hear it in the comments. 👇

Landing page: six tools, one assistant<br>
![Marketplace with seeded fertilizer, crop-protection and seed products<br>
![Product detail with rating and add-to-cart<br>
![Assistant answering a fertilizer-dose question with the calculator tool<br>
![Crop recommendation from soil N-P-K, pH, climate<br>
![Fertilizer pick from soil-test nutrient deficit<br>
![Yield prediction with a prediction band<br>
![Disease detection on a field photo<br>
![7-day forecast and agro-advisories<br>
![Central scheme lookup with eligibility and links<br>
![Admin console: farmers, orders, activity, chat logs](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/f4vnfzog0gx1qvzt5tgo.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/ooreynf3x79vz2u0a5lu.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/mh84ue5vs3wr8wdxac59.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/ffjn4x2l1k977ve6vdrf.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/ix29mfjl564nekojurg5.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/nvhaxgcrmycfhxwcf8ap.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/iykryoa9w34vppufwrjw.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/puk9hf6o5vdn6fcgrjvi.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/cuk5yd0guve8i3ffgw3a.png)](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/pzfr8xjwq8evem11xc7a.png)