Tunisia-optimized crop disease detection API — ViT 55 classes, ONNX Runtime, FastAPI, nginx
# CropNet API 🌾
Multi-model crop disease diagnosis for Tunisian agriculture. **1 general model + 8 specialist models**, all running ONNX inference on a single VPS.
> **⚠️ Advisory Only** — CropNet provides AI-generated agricultural guidance. All predictions are advisory and should be verified by a qualified agronomist before making critical decisions. Low-confidence results are explicitly flagged. Do not use this system as a sole basis for treatment decisions.
## Architecture
```
┌──────────────────────┐
│ Client App │
│ (Fellah Web/Mobile) │
└──────────┬───────────┘
│ POST /predict
▼
┌──────────────────────┐
│ CropNet API v5 │
│ FastAPI + Uvicorn │
└──────────┬───────────┘
│
┌────────────────────┬┴┬────────────────────┐
▼ ▼ ▼
┌────────────────┐ ┌─────────────────┐ ┌────────────────┐
│ Preprocessing │ │ General Model │ │ Localization │
│ 256×256 + TTA │ │ DINOv2-B (v4) │ │ AR / FR / EN │
└────────────────┘ │ 89 classes │ └────────────────┘
│ 85.8% val acc │
└────────┬──────────┘
│ top-k predictions
▼
┌─────────────────┐
│ Crop Family │
│ Router │
│ (CROP_FAMILIES) │
└────────┬────────┘
│ match?
┌───────┬───────┬───┴───┬───────┬───────┬───────┬───────┐
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
┌──────┐┌──────┐┌──────┐┌──────┐┌──────┐┌──────┐┌──────┐┌──────┐
│🫒 ││🌴 ││🌾 ││🍊 ││🍑 ││🍅 ││🌶️ ││🍉 │
│Olive ││D.Palm││Wheat ││Citrus││Peach ││Tomato││Pepper││W.melon│
│99.6% ││100% ││100% ││98.4% ││100% ││99.9% ││100% ││100% │
└──────┘└──────┘└──────┘└──────┘└──────┘└──────┘└──────┘└──────┘
Tier 1 Tier 1 Tier 1 Tier 1 Tier 1 Tier 2 Tier 2 Tier 2
```
### How It Works
1. **Photo in** → 256×256 resize + 5-crop TTA (center + 4 corners at 90% scale)
2. **General model** classifies across 89 diseases/conditions
3. **Router** scans top-k predictions for crop family keywords (e.g. "Olive___" → olive special …