/zd-ml:train-templatefrom Zaraat Dost · ML
Provides a structured template for PyTorch segmentation training scripts with resume, early stopping, cosine LR scheduling, AMP, full-state checkpoints, and tiled inference for large rasters.
Ships in Zaraat Dost · ML. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
config (yaml/argparse) → seed → build datasets (split by ID, deepcopy transforms)
→ model (smp.Unet / smp.UnetPlusPlus / SegFormer via transformers; encoder e.g. tu-hrnet_w48, resnet34)
→ loss (Dice+CE or focal; ignore_index for nodata) → AdamW → CosineAnnealingWarmRestarts or OneCycle
→ AMP (torch.autocast + GradScaler) → loop:
train epoch → val (per-class IoU/F1) → log CSV/JSONL → save last.pt every epoch
→ save best.pt on val mIoU improvement → early stop after N epochs w/o improvement
→ final: evaluate best.pt on test, write model_card.md, export ONNX (optional)
Checkpoint dict: {'epoch', 'model_state_dict', 'optimizer_state_dict', 'scheduler_state_dict', 'scaler_state_dict', 'best_metric', 'config', 'git_sha'}. --resume path restores all of it.
Fine-tuning: lower LR for encoder (10×), unfreeze decoder first for 1–2 epochs, then all; keep the original normalisation stats.
Inference on large rasters: tile with overlap (e.g. 512 px, 64 overlap), predict, blend by centre-weighted mask, write with rasterio windows to a COG (driver='COG'); then hand off to zd-vector.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub adilmunawar/zd-claude-plugin --plugin zd-ml4 skills in this plugin
/colab-ram-safePatterns for RAM-limited notebooks: windowed reads, patch shards, progress files, Drive checkpoints./model-cardWrite an HF-compatible model card (data, classes, metrics, limits) next to a checkpoint./seg-preflightTen-point checklist that catches common segmentation-pipeline bugs (checkpoint keys, shared dataset refs, split leakage, nodata, class balance). Apply before any training run or when predictions are garbage.Other plugins' skills for the same job