Running the Image Processing Tool's default augmentation (factor 5, random ±5°) on 2448×2048 PNGs took about 4.3 seconds per image. Preparing a few thousand training images took hours.
Where the time went
Profiling showed the bottleneck was not rotation or alignment but saving. More than 90% of the run time was spent in PIL's PNG encoder at its default compression level 6.
What changed
- PNG compression level 1 — still lossless, about 5× faster to encode, roughly 10% larger files.
- Parallel output saving — the six outputs per input are written concurrently with a
ThreadPoolExecutor(up to 8 threads). The PIL encoder releases the GIL, so it scales with cores. - Simpler rotation —
rotate(expand=True)followed by a center crop became a singlerotate(expand=False). Same result, half the cost. - Log throttling — per-file logs now print once every 10 files.
Result
| v1.6.1 | v1.6.2 | |
|---|---|---|
| Time per image | ~4.3 s | ~0.26 s |
| Output size | baseline | ~+10% |
| Config format | — | unchanged |
Fewer than 0.003% of pixels differ at the rotation boundary, with no effect on augmentation quality.