Day 53: Fine-tuning YOLO: training run, augmentation, hyperparameters
Running the fine-tune
With data ready, fine-tuning is a few lines — Ultralytics handles the training loop, augmentation, and logging. You start from pretrained weights (transfer learning again — Day 37's principle) so the model already knows general visual features and only needs to learn your classes. The key knobs: epochs, image size, batch size, and the built-in augmentation.
from ultralytics import YOLO
model = YOLO("yolov8s.pt") # start from pretrained (transfer learning)
model.train(
data="garment_dataset/data.yaml",
epochs=100,
imgsz=640,
batch=16,
patience=20, # early stopping if val stops improving
augment=True, # mosaic, flips, HSV jitter, etc.
device=0, # GPU (Kaggle T4)
)YOLO's augmentation is doing a lot
Ultralytics applies strong augmentation by default — mosaic (stitching four images), random flips, HSV color jitter, scaling. This is Day 38–39's overfitting defense, built in. For small garment datasets it's essential; it multiplies your effective data and is a big reason YOLO fine-tunes well on modest datasets.
Train on Kaggle's free T4 (the roadmap keeps Stage 2 at ₹0 compute). Watch the training plots Ultralytics generates — box loss, class loss, and mAP over epochs are your Day-40 learning curves in detection form. If mAP plateaus early, you likely need more or better-labelled data, not more epochs.
Key terms
- Mosaic augmentation
- Stitching four training images into one, exposing the detector to varied scales and contexts — a YOLO default.
- imgsz
- The input image size YOLO trains and infers at; larger sees more detail but costs more compute.
- patience
- Epochs to wait for validation improvement before early-stopping the training run.
You fine-tune YOLO and mAP plateaus after 30 epochs despite 100 epochs scheduled. What is the most likely productive next step?