This repository is intended as a faster drop-in replacement for Pytorch's Torchvision augmentations. This repo uses OpenCV for fast image augmentation for PyTorch computer vision pipelines. I wrote this code because the Pillow-based Torchvision transforms was starving my GPU due to slow image augmentation.
Requirements
A working installation of OpenCV. Tested with OpenCV version 3.4.1
Tested on Windows 10. There is evidence that OpenCV doesn't work well with multithreading on Linux / MacOS, for example num_workers >0 in a pytorch DataLoader. I haven't tried this on those systems.
An example benchmarking file can be found in the notebook bencharming_v2.ipynb I wrapped the Cityscapes default directories with a HDF5 file for even faster reading.
The changes start to add up when you compose multiple transformations together.
TODO
Initial commit with all currently implemented torchvision transforms
Cityscapes benchmarks
Make the resample flag on RandomRotation, RandomAffine actually do something
Speed up augmentation in saturation and hue. Currently, fastest way is to convert to a PIL image, perform same augmentation as Torchvision, then convert back to np.ndarray