Views
No views yet
timm for a vast array of pre-trained backbones (e.g., EfficientNetV2, ConvNeXtV2, EVA02) and offers advanced training features such as Exponential Moving Average (EMA) for weights, Layer-wise Learning Rate Decay (LLRD), MixUp/CutMix data augmentation, and Weights & Biases (W&B) integration for experiment tracking.timm.vit, convnextv2.omegaconf (YAML config files).| Model | mAP | Accuracy |
|---|---|---|
| EfficientNetV2 Small | 0.87 | 0.815 |
| DINOv3 ViT Small Plus | 0.91 | 0.830 |
| ConvNeXtV2 Tiny | 0.94 | 0.860 |
Plant-Disease-Classification/
├── configs/
│ └── config.yaml # Main configuration file
├── data/
│ ├── train/ # Train data (organized by class folders)
│ └── val/ # Val data (organized by class folders)
├── src/
│ ├── dataset.py # Dataloaders and augmentation logic
│ ├── infer.py # Inference script and prediction utilities
│ ├── loss.py # Loss functions (CrossEntropy, Focal Loss)
│ ├── metrics.py # Metric calculations
│ ├── models.py # Model definitions and param groupings
│ ├── trainer.py # Core training loop
│ └── utils.py # Helpers (schedulers, seeds, config loading)
├── train.py # Main entrypoint for training
└── requirements.txt # Project dependenciesuv for fast, reliable package management.1# Create a virtual environment using uv
2uv venv
3
4# Activate the environment
5source .venv/bin/activate # Linux/MacOS
6
7# Install dependencies rapidly
8uv pip install -r requirements.txtImageFolder format. Place the training data in data/train and validation data in data/val. Each subplot or leaf should be in its corresponding disease or health category folder.1data/
2└── train/
3 ├── Apple scab/
4 └── ...configs/config.yaml.python train.py --config configs/config.yaml--resume argument:python train.py --config configs/config.yaml --resume checkpoints/checkpoint.pthpython train.py --config configs/config.yaml --init_weights weights/pretrained.pthsrc/infer.py script. The script requires a serialized TorchScript model checkpoint.1# Basic inference
2python src/infer.py --image_path path/to/leaf.jpg --checkpoint checkpoints/best_model.pt --image_size 384
3
4# Inference with Test Time Augmentation (TTA)
5python src/infer.py --image_path path/to/leaf.jpg --checkpoint checkpoints/best_model.pt --image_size 384 --ttaNote: The inference script expects adata/label_map.jsonfile to map class indices to disease names.
timm.create_model(...). You can specify any model architecture available in timm (e.g. convnextv2_base, efficientnet_b0, eva02_base_patch14_448) directly in the config.yaml file under model.backbone.OmegaConf. Hyperparameters such as loss, optimizer, and augmentation can be tweaked. For example, to enable layer-wise learning rate decay, adjust optimizer.layer_decay to a value < 1.0.checkpoints/ directory (customizable via logging.checkpoint_dir).logging.use_wandb is true, the script initializes a Weights & Biases run, logging train/validation losses and selected metrics seamlessly.