skills/cv/keypoint-aware-raster-augmentation/SKILL.md
Use albumentations keypoint_params to jointly augment BEV rasters and trajectory target points so the spatial transform stays consistent
npx skillsauth add wenmin-wu/ds-skills cv-keypoint-aware-raster-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.
BEV rasters paired with trajectory targets (lists of (x, y) points) cannot be augmented with image-only transforms — a horizontal flip of the raster without flipping the trajectory produces a garbage training pair. Albumentations supports this natively via KeypointParams: pass the trajectory points as keypoints, and the library applies the exact same geometric transform to both the image and the points. This unlocks shift/scale/rotate/flip/cutout on motion-prediction data with zero custom code.
import albumentations as A
import numpy as np
tfms = A.Compose([
A.HorizontalFlip(p=0.5),
A.ShiftScaleRotate(shift_limit=0.05, scale_limit=0.1,
rotate_limit=15, p=0.7),
A.CoarseDropout(max_holes=4, max_height=16, max_width=16, p=0.3),
], keypoint_params=A.KeypointParams(format='xy', remove_invisible=False))
def augment(sample):
image = sample['image'].transpose(1, 2, 0) # (C,H,W) -> (H,W,C)
kps = sample['target_positions'].tolist() # [(x,y), ...]
out = tfms(image=image, keypoints=kps)
sample['image'] = out['image'].transpose(2, 0, 1)
sample['target_positions'] = np.array(out['keypoints'], dtype=np.float32)
return sample
A.Compose pipeline with any mix of geometric and pixel transformskeypoint_params=A.KeypointParams(format='xy', remove_invisible=False) — remove_invisible=False is critical so flipped points outside the image aren't silently dropped__getitem__, convert the raster from (C,H,W) to (H,W,C) and pass it with keypoints=target_pointsremove_invisible=False: without this, horizontal flip drops negative-x points and desyncs lengths.data-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