-
Load a pretrained CNN backbone (e.g.,
ResNet50pretrained on ImageNet). -
Replace the classification head with a new fully connected layer:
nn.Linear(2048, num_classes)for ResNet50.
-
Freeze all layers except the classification head.
-
Resize inputs to the resolution expected by the pretrained model (e.g., 384×384).
-
Normalize images using pretrained stats (ImageNet mean & std).
-
Apply augmentation:
- Basic: random crop, horizontal flip, small rotations.
- Learning rate:
- Batch size:
- Epochs:
- Optimizer:
- AdamW (fast convergence, but watch for overfitting).
- Weight decay:
1e-4(regularization).
- Warm-up: start small (
1e-6) and ramp to base LR over 5–10 epochs. - Decay:
- Step decay (×0.1 every 30 epochs).
- Scheduler:
StepLR,CosineAnnealingLR, orOneCycleLR.
- Use data augmentation to increase variability.
- Add dropout (0.2–0.5) in classifier head.
- Apply early stopping based on validation loss.