Crop distress prediction from satellite and weather data using a cross-attention transformer (KisanNet v3).
Project description
Krishikarm
Crop distress prediction from satellite and weather data.
Krishikarm uses KisanNet v3, a cross-attention transformer trained on 82,000+ real satellite observations across 127 Indian districts, to predict crop health risk in real time.
Installation
pip install krishikarm
Quick Start
from krishikarm import Predictor
predictor = Predictor()
result = predictor.predict({
"lat": 12.97,
"lon": 77.59,
"T2M": 32,
"RH2M": 65,
"PREC": 2.5,
"SOLAR": 18,
"WIND": 3,
"state": "KA",
"irrig": "borewell",
"crops": ["rice"],
})
print(result)
# {
# "distress_score": 0.12,
# "intervention_days": 26.4,
# "risk_class": 0,
# "risk_label": "Healthy"
# }
Model Architecture
KisanNet v3 is a cross-attention transformer with:
- 42 input features derived from weather, soil, atmosphere, and location data
- State and irrigation embeddings for regional context
- 4-layer, 8-head cross-attention fusion between satellite and context encoders
- Three prediction heads: distress score (0-1), intervention window (days), risk class (5 levels)
- 96.8% accuracy on held-out test data
Input Features
| Source | Features |
|---|---|
| Weather | Temperature, humidity, precipitation, wind, cloud cover, dew point |
| Solar | Shortwave radiation, UV index, longwave radiation |
| Soil | Moisture (3 depths), temperature (2 depths), clay, sand, SOC, pH |
| Atmosphere | PM2.5, PM10, dust, aerosol optical depth |
| Derived | NDVI proxy, VPD, GDD, thermal range |
| Location | Latitude, longitude, elevation, day-of-year encoding |
Risk Classes
| Class | Label | Distress Range |
|---|---|---|
| 0 | Healthy | 0.00 - 0.15 |
| 1 | Watch | 0.15 - 0.30 |
| 2 | Alert | 0.30 - 0.50 |
| 3 | Critical | 0.50 - 0.75 |
| 4 | Emergency | 0.75 - 1.00 |
Data Sources
All training data was collected from free, open APIs:
- NASA POWER -- Solar radiation, temperature, humidity
- Open-Meteo -- Weather forecasts, soil moisture, UV, air quality
- SoilGrids -- Soil composition (clay, sand, SOC, pH)
- Open-Elevation -- Terrain altitude
No proprietary data or paid APIs were used.
API Reference
Predictor
Predictor(weights_path=None, device=None)
weights_path-- Path to a.pthcheckpoint. Defaults to the bundled v3 weights.device--"cpu"or"cuda". Defaults to CUDA when available.
Methods
predict(observation: dict) -> dict-- Run prediction on a single observation.predict_batch(observations: list[dict]) -> list[dict]-- Batch prediction.info() -> dict-- Return model metadata.
KisanNetV3
The raw PyTorch model class, for advanced users who want to integrate the architecture into their own training pipeline.
Requirements
- Python >= 3.9
- PyTorch >= 2.0
- NumPy >= 1.24
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file krishikarm-0.1.0.tar.gz.
File metadata
- Download URL: krishikarm-0.1.0.tar.gz
- Upload date:
- Size: 14.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dd964b869c8a0059d6efa3dfcdd828a9de88daa5dd78784e40e80978cbccfa2
|
|
| MD5 |
3afe7246a7094a200d75b040d5a94a69
|
|
| BLAKE2b-256 |
5fb82da4f422b0bd7a8c69e4fe7506a06b23e41b1f81ca0e1ee240840c5748b5
|
Provenance
The following attestation bundles were made for krishikarm-0.1.0.tar.gz:
Publisher:
workflow.yml on varshinicb1/Krishikarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krishikarm-0.1.0.tar.gz -
Subject digest:
1dd964b869c8a0059d6efa3dfcdd828a9de88daa5dd78784e40e80978cbccfa2 - Sigstore transparency entry: 960143049
- Sigstore integration time:
-
Permalink:
varshinicb1/Krishikarm@048d4b2f7452e0d53c5174b8ac777b9c618e88f1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/varshinicb1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@048d4b2f7452e0d53c5174b8ac777b9c618e88f1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file krishikarm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: krishikarm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35c3bb09852bba3d694945bda6d2588b085c36435f36c50a40782c71b52d78e7
|
|
| MD5 |
4d9ee114500f8e5f87947b4f7aee2842
|
|
| BLAKE2b-256 |
f67885eb32ad574d9d3e35cff176ea920a128b7d0a9d646ac9143e572939a8d6
|
Provenance
The following attestation bundles were made for krishikarm-0.1.0-py3-none-any.whl:
Publisher:
workflow.yml on varshinicb1/Krishikarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krishikarm-0.1.0-py3-none-any.whl -
Subject digest:
35c3bb09852bba3d694945bda6d2588b085c36435f36c50a40782c71b52d78e7 - Sigstore transparency entry: 960143117
- Sigstore integration time:
-
Permalink:
varshinicb1/Krishikarm@048d4b2f7452e0d53c5174b8ac777b9c618e88f1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/varshinicb1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@048d4b2f7452e0d53c5174b8ac777b9c618e88f1 -
Trigger Event:
release
-
Statement type: