Instructions to use RaiyanKhaan/KrishokTech-Models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use RaiyanKhaan/KrishokTech-Models with ultralytics:
# Couldn't find a valid YOLO version tag. # Replace XX with the correct version. from ultralytics import YOLOvXX model = YOLOvXX.from_pretrained("RaiyanKhaan/KrishokTech-Models") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
KrishokChat: Agricultural Vision & Soil Intelligence Model Suite
This repository contains the complete, production-ready suite of machine learning models developed for the KrishokChat Advisory System. These models are packaged into self-contained, folderized directories to enable academic reviewers, agronomists, and developers to reproduce and run our full diagnostic pipeline locally without requiring expensive cloud GPU servers.
1. Architectural Overview
The KrishokChat perception and diagnostic stack uses a multi-tier decoupled architecture:
- Tier 1: Crop Species Identification β A
YOLO26-clsmodel identifying 10 major crop families in Bangladesh to eliminate cross-crop pesticide misbinding hazard. - Tier 2: Specialized Crop Pathology Diagnosis β Six per-crop dedicated
YOLO26-clsmodels diagnosing foliar fungal, bacterial, viral, and physiological diseases. - Tier 3: Soil Moisture Matric Tension Estimation β A 5-fold cross-validated
EfficientNet-B0regression model predicting continuous soil suction pressure ($\text{kPa}$) directly from field images for precision irrigation guidance.
[ Farmer Field Leaf Image ]
β
βΌ
[ 01_crop_classifier ] (YOLO26-cls)
βββββββββββββββββββΌββββββββββββββββββ
β β β
βΌ βΌ βΌ
[ 02_potato_disease ] [ 03_rice_disease ] [ 04_wheat_disease ] ...
β β β
βββββββββββββββββββΌββββββββββββββββββ
βΌ
[ Diagnosis + Bangla Treatment Advice ]
2. Model Catalog & Checkpoint Manifest
Every PyTorch weight (.pt) is named distinctively with zero ambiguity. Corresponding optimized ONNX weights are included for cross-platform edge deployment.
| # | Directory | PyTorch Weight (.pt) |
Edge ONNX (.onnx) |
Architecture | Classes / Output | Target Crop / Task |
|---|---|---|---|---|---|---|
| 1 | 01_crop_classifier |
crop_classifier.pt (10.5 MB) |
crop_classifier.onnx (20.8 MB) |
YOLO26-cls | 10 classes | Multi-crop species classification |
| 2 | 02_potato_disease |
potato_disease.pt (10.5 MB) |
potato_disease.onnx (20.8 MB) |
YOLO26-cls | 3 classes | Potato (Solanum tuberosum) |
| 3 | 03_rice_disease |
rice_disease.pt (19.9 MB) |
rice_disease.onnx (39.6 MB) |
YOLO26-cls | 10 classes | Rice (Oryza sativa) |
| 4 | 04_wheat_disease |
wheat_disease.pt (9.0 MB) |
wheat_disease.onnx (5.9 MB) |
YOLO26-cls | 11 classes | Wheat (Triticum aestivum) |
| 5 | 05_corn_disease |
corn_disease.pt (10.5 MB) |
corn_disease.onnx (20.8 MB) |
YOLO26-cls | 4 classes | Corn / Maize (Zea mays) |
| 6 | 06_chilli_disease |
chilli_disease.pt (3.1 MB) |
chilli_disease.onnx (5.9 MB) |
YOLO26-cls | 8 classes | Chilli (Capsicum annuum) |
| 7 | 07_brassica_disease |
brassica_disease.pt (10.5 MB) |
brassica_disease.onnx (20.8 MB) |
YOLO26-cls | 11 classes | Cabbage & Cauliflower (Brassica spp.) |
| 8 | 08_soil_moisture |
effnetb0_fold[0-4].pt (81 MB) |
N/A (PyTorch state_dict) | EfficientNet-B0 | 1 continuous (kPa) | Soil matric tension estimation |
3. Directory Layout
backend_models/
βββ README.md # Main Model Card & Reviewer Documentation
βββ requirements.txt # Minimal pip dependencies
βββ verify_all_models.py # Single-click automated diagnostic verification suite
βββ run_inference.py # Multi-model CLI inference runner
βββ upload_to_huggingface.py # Hugging Face Hub upload automation script
β
βββ 01_crop_classifier/ # Intake Crop Classifier (10 classes)
β βββ crop_classifier.pt
β βββ crop_classifier.onnx
β βββ class_names.json
β βββ README.md
β
βββ 02_potato_disease/ # Potato Pathology (Early Blight, Late Blight, Healthy)
β βββ potato_disease.pt
β βββ potato_disease.onnx
β βββ class_names.json
β βββ disease_details.json
β βββ README.md
β
βββ 03_rice_disease/ # Rice Pathology (Blast, BLB, Sheath Blight, etc.)
β βββ rice_disease.pt
β βββ rice_disease.onnx
β βββ class_names.json
β βββ disease_details.json
β βββ README.md
β
βββ 04_wheat_disease/ # Wheat Pathology (Rusts, Blast, Tan Spot, etc.)
β βββ wheat_disease.pt
β βββ wheat_disease.onnx
β βββ class_names.json
β βββ disease_details.json
β βββ metadata.json
β βββ README.md
β
βββ 05_corn_disease/ # Corn Pathology (Rust, Leaf Spot, Blight)
β βββ corn_disease.pt
β βββ corn_disease.onnx
β βββ class_names.json
β βββ disease_details.json
β βββ README.md
β
βββ 06_chilli_disease/ # Chilli Pathology (Bacterial Spot, Curl Virus, etc.)
β βββ chilli_disease.pt
β βββ chilli_disease.onnx
β βββ class_names.json
β βββ disease_details.json
β βββ README.md
β
βββ 07_brassica_disease/ # Crucifers (Cabbage / Cauliflower diseases)
β βββ brassica_disease.pt
β βββ brassica_disease.onnx
β βββ class_names.json
β βββ disease_details.json
β βββ README.md
β
βββ 08_soil_moisture/ # Soil Moisture Tensiometer Regression (5-fold ensemble)
β βββ effnetb0_fold0.pt ... fold4.pt
β βββ oof_predictions.csv
β βββ pred_vs_actual.png
β βββ model_def.py
β βββ README.md
β
βββ sample_images/ # Representative leaf images for zero-setup verification
βββ crop_sample.jpg
βββ potato_sample.jpg
βββ rice_sample.jpg
βββ wheat_sample.jpg
βββ corn_sample.jpg
βββ chilli_sample.jpg
βββ brassica_sample.jpg
4. Quickstart Guide for Academic Reviewers
Step 1: Install Dependencies
cd backend_models
pip install -r requirements.txt
Step 2: Automated Verification of All Models
Run the automated test runner to verify that every single model checkpoint loads into memory, performs forward inference, and verifies against class specifications:
python verify_all_models.py
Step 3: Run Standalone Inferences
Test Potato Disease Diagnosis:
python run_inference.py --crop potato --image sample_images/potato_sample.jpg
Test Rice Disease Diagnosis:
python run_inference.py --crop rice --image sample_images/rice_sample.jpg
Test Wheat Disease Diagnosis:
python run_inference.py --crop wheat --image sample_images/wheat_sample.jpg
Test Soil Moisture Regression:
python run_inference.py --task soil --image sample_images/crop_sample.jpg
5. Python API Usage
Vision Models (YOLO26)
from ultralytics import YOLO
# Load any specialized YOLO26 pathology classifier
model = YOLO("02_potato_disease/potato_disease.pt")
# Predict on an RGB image
results = model.predict("sample_images/potato_sample.jpg", imgsz=224, verbose=False)[0]
top_class = model.names[results.probs.top1]
confidence = float(results.probs.top1conf)
print(f"Result: {top_class} ({confidence:.2%})")
Soil Moisture Regression (5-Fold Ensemble)
import sys
sys.path.insert(0, "08_soil_moisture")
from model_def import load_soil_model
import torch
import torchvision.transforms as T
from PIL import Image
transform = T.Compose([
T.Resize((224, 224)),
T.ToTensor(),
T.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
img = transform(Image.open("sample_images/crop_sample.jpg").convert("RGB")).unsqueeze(0)
# Ensemble average across 5 folds
predictions = []
for fold in range(5):
m = load_soil_model(f"08_soil_moisture/effnetb0_fold{fold}.pt")
with torch.no_grad():
predictions.append(m(img).item())
mean_kpa = sum(predictions) / len(predictions)
print(f"Estimated Soil Matric Potential: {mean_kpa:.2f} kPa")
6. Uploading to Hugging Face Hub
To publish this suite to the official Hugging Face repository:
python upload_to_huggingface.py --token <YOUR_HF_TOKEN>
Target repository: https://huggingface.co/RaiyanKhaan/KrishokTech-Models
7. Citation
If you use these model weights or the KrishokChat pipeline in your research, please cite our paper:
@inproceedings{krishokchat2026,
title={KrishokChat: A Grounded Multi-Modal Agricultural Advisory and Pathology Diagnostic System for Smallholder Farming},
author={Reza, Raiyaan and Khaan, Raiyan and Collaborators},
booktitle={Proceedings of the European Chapter of the Association for Computational Linguistics (EACL)},
year={2026}
}
- Downloads last month
- 140