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.
- Upload a leaf photo — tomato, potato or corn (maize).
- Detect a possible disease — a trained MobileNetV3-Large model predicts one of 17 classes (diseased or healthy).
- Show confidence and top-3 guesses — so the farmer sees how sure the model is.
- Estimate visible severity — a simple, transparent colour-based estimate of how much of the leaf appears damaged.
- 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.
- Give plain guidance — symptoms, farmer actions and prevention tips written in everyday language, with an Urdu header for local users.
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
Windows (Command Prompt):
.venv\Scripts\activate.bat
Windows (PowerShell):
.venv\Scripts\Activate.ps1
Git Bash:
source .venv/Scripts/activate
python -m pip install -r requirements.txt
The existing .venv already has everything installed, so you normally
skip this step.
python tests/test_environment.py
python tests/test_weather.py
.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.
- 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.
- 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.