Task: Build a Reproducible Augmentation Pipeline for Grayscale Digit Denoising
Context
You are training a denoising model on grayscale digit images (e.g., MNIST-like, shape [B, 1, H, W]). The model should learn to reconstruct a clean image from a corrupted input. To improve robustness and generalization, implement a data augmentation pipeline that:
-
Applies geometry-preserving transforms identically to both input and target (paired transforms), so the supervised target remains aligned.
-
Applies corruption-only transforms to the input branch to simulate noise, while keeping the target branch clean.
-
Uses in-place operations where it is safe and appropriate.
-
Is seeded and structured for reproducibility.
-
Includes a quick visualization to compare a batch before/after augmentation.
Requirements
-
Implement approximately 10 augmentations suitable for grayscale digits for denoising training, including:
-
Geometry (paired): random resize/scale jitter, random crop, rotations, translations, flips, affine shear, elastic distortion.
-
Corruptions (input-only): brightness/contrast jitter, Gaussian noise, cutout/random erasing.
-
Use in-place operations where they are safe; explain where in-place is unsafe (autograd and aliasing concerns).
-
Provide before/after visualizations for a batch: Original vs Clean (paired-transformed) vs Noisy (input-only corrupted).
-
Show how to seed and structure the pipeline for reproducibility (global seeds, per-worker seeding, generators, deterministic algorithms).
-
You may assume PyTorch/torchvision and standard plotting tools are available. Keep the code concise and suitable for a technical screen under time constraints.