Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KisanVision AI

KisanVision AI is an AI-powered smart agriculture demo for Pakistani farmers. A farmer uploads a photo of a crop leaf, and the app explains what the model sees and what to do next.

What the demo can do now

  1. Upload a leaf photo — tomato, potato or corn (maize).
  2. Detect a possible disease — a trained MobileNetV3-Large model predicts one of 17 classes (diseased or healthy).
  3. Show confidence and top-3 guesses — so the farmer sees how sure the model is.
  4. Estimate visible severity — a simple, transparent colour-based estimate of how much of the leaf appears damaged.
  5. Analyse weather risk — fetches free, keyless weather from Open-Meteo for a city the farmer enters, then shows a rule-based risk estimate for the detected disease. This is clearly separated from the AI diagnosis and never changes it.
  6. Give plain guidance — symptoms, farmer actions and prevention tips written in everyday language, with an Urdu header for local users.

Project structure

Kisain Vision Ai/
├── app/                     # application code
│   ├── __init__.py          # marks "app" as a Python package
│   ├── config.py            # paths & settings in one place
│   ├── dataset.py           # dataset loading and transforms
│   ├── disease_info.py      # farmer-facing disease guidance
│   ├── image_processing.py  # image load / convert / resize / save
│   ├── model_handler.py     # load and run the trained model
│   ├── severity.py          # image-based visible severity estimate
│   ├── weather.py           # Open-Meteo weather client
│   ├── weather_risk.py      # rule-based weather-disease risk engine
│   └── utils.py             # small shared helpers
├── data/                    # PlantVillage dataset (not committed)
├── models/                  # trained PyTorch checkpoints
│   ├── best_model.pt
│   └── best_model_17class.pt
├── notebooks/               # Jupyter experiments
├── tests/                   # checks for environment, weather, etc.
├── .venv/                   # Python virtual environment
├── requirements.txt         # pinned package versions
├── streamlit_app.py         # demo web app entry point
└── README.md                # this file

Getting started

1. Activate the virtual environment

Windows (Command Prompt):

.venv\Scripts\activate.bat

Windows (PowerShell):

.venv\Scripts\Activate.ps1

Git Bash:

source .venv/Scripts/activate

2. Install dependencies (only needed on a new machine)

python -m pip install -r requirements.txt

The existing .venv already has everything installed, so you normally skip this step.

3. Verify the environment

python tests/test_environment.py
python tests/test_weather.py

4. Run the Streamlit demo

.venv\Scripts\python.exe -m streamlit run streamlit_app.py

The demo uses the 17-class checkpoint at models/best_model_17class.pt. If the checkpoint is missing, the app shows a friendly "model not available" screen instead of crashing.

Weather risk analysis

  • Provider: Open-Meteo (free, no API key required).
  • Default location: Lahore, Pakistan.
  • Weather is cached for 15 minutes so the app stays responsive.
  • If the weather service is offline or the city is not found, the app shows a friendly message and keeps the diagnosis, severity, top-3 and guidance fully visible.
  • Turn weather risk analysis off with the checkbox in the sidebar if you do not want any network calls.

Notes

  • PyTorch is installed as the CPU-only build. Predictions run fine on a normal laptop.
  • The weather risk is a rule-of-thumb estimate based on pathogen family and current conditions. It is not a laboratory forecast and does not replace local extension advice.
  • For severe outbreaks, always confirm with your local agriculture extension office.

About

AI-powered crop disease detection and farmer advisory system

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages