R&D
CENTER

The bottleneck was the PNG encoder — a 16× faster augmentation

Over 90% of augmentation time went into PIL's PNG encoder. One compression level and parallel saving took each image from 4.3 s to 0.26 s.

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

  1. PNG compression level 1 — still lossless, about 5× faster to encode, roughly 10% larger files.
  2. 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.
  3. Simpler rotation — rotate(expand=True) followed by a center crop became a single rotate(expand=False). Same result, half the cost.
  4. 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.