Skip to content
Back to skills

Train Template

ASecurity

Structure for a PyTorch segmentation training script: resume, early stopping, cosine LR, AMP, full-state checkpoints, tiled inference.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 19, 2026
ai-agentsgit

Security analysis

A100/100

Scanned September 19, 2026

npx -y skills add Adilmunawar/ZD-claude-plugin --skill train-template --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Train Template?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Train Template
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adilmunawar-train-template/badge)](https://www.skillsdirectory.com/skills/adilmunawar-train-template)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: train-template
description: Structure for a PyTorch segmentation training script: resume, early stopping, cosine LR, AMP, full-state checkpoints, tiled inference.
---

# Training script template (structure, not boilerplate to paste blindly)

```
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…