skills/cv/rotation-tta-segmentation/SKILL.md
Test-time augmentation via 4 rotation angles (0/90/180/270), applying inverse rotation to each prediction before averaging
npx skillsauth add wenmin-wu/ds-skills cv-rotation-tta-segmentationInstall 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.
For segmentation tasks without strong orientation priors (microscopy, satellite, scroll fragments), rotating the input by 0°, 90°, 180°, and 270° and averaging the inverse-rotated predictions reduces directional bias. This is computationally efficient — all 4 rotations can be batched into a single forward pass by concatenating along the batch dimension.
import torch
def rotation_tta(model, x):
B = x.shape[0]
# Create 4 rotated versions, batch together
rotated = [x] + [torch.rot90(x, k=k, dims=(-2, -1)) for k in range(1, 4)]
batch = torch.cat(rotated, dim=0) # (4*B, C, H, W)
with torch.no_grad():
preds = torch.sigmoid(model(batch))
# Split and inverse-rotate
preds = preds.reshape(4, B, *preds.shape[1:])
aligned = [torch.rot90(preds[k], k=-k, dims=(-2, -1)) for k in range(4)]
return torch.stack(aligned, dim=0).mean(0)
pred = rotation_tta(model, images.cuda())
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