skills/cv/albumentations-detection-augmentation/SKILL.md
Applies albumentations augmentations to object detection data while preserving bbox-label correspondence via BboxParams.
npx skillsauth add wenmin-wu/ds-skills cv-albumentations-detection-augmentationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Albumentations supports spatial transforms (flip, rotate, crop, resize) that automatically adjust bounding boxes alongside the image. The key is BboxParams — it tells the pipeline the bbox format (pascal_voc, coco, yolo) and which field maps labels to boxes. Without this, augmented bboxes get shuffled or lost. This pattern wraps albumentations into a detection framework's data mapper (Detectron2, MMDetection) or a custom PyTorch Dataset.
import albumentations as A
import numpy as np
# Define augmentation pipeline with bbox support
transform = A.Compose([
A.HorizontalFlip(p=0.5),
A.RandomBrightnessContrast(p=0.3),
A.ShiftScaleRotate(shift_limit=0.05, scale_limit=0.1,
rotate_limit=15, p=0.5),
A.RandomResizedCrop(height=512, width=512, scale=(0.8, 1.0), p=0.5),
], bbox_params=A.BboxParams(
format='pascal_voc', # [x_min, y_min, x_max, y_max]
label_fields=['category_ids'],
min_area=100, # drop tiny boxes after crop
min_visibility=0.3, # drop mostly-clipped boxes
))
# Apply to image + bboxes
bboxes = [[100, 100, 300, 300], [400, 200, 500, 400]]
labels = [0, 1]
result = transform(
image=image,
bboxes=bboxes,
category_ids=labels,
)
aug_image = result['image']
aug_bboxes = result['bboxes'] # transformed coordinates
aug_labels = result['category_ids'] # preserved correspondence
A.Compose and A.BboxParamspascal_voc, coco (x,y,w,h), or yolo (normalized)min_area and min_visibility to drop degenerate boxes after cropping__getitem__ or framework-specific mapperpascal_voc for [x1,y1,x2,y2], yolo for normalized [cx,cy,w,h]label_fields links labels to bboxes; without it, augmented boxes lose their class IDsdata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF