Skip to main content

Efficient vision data augmentations for CPU/GPU per-sample/batched data.

This repository is now archived as I work on other projects. I do not plan to reopen it any time soon.

PyPI python PyPI version documentation codecov License

Torchaug

Introduction

Torchaug is a data augmentation library for the Pytorch ecosystem. It is meant to deal efficiently with tensors that are either on CPU or GPU and either per sample or on batches.

It enriches Torchvision (v2) that has been implemented over Pytorch and Pillow to, among other things, perform data augmentations. Because it has been implemented first with per-sample CPU data augmentations in mind, it has several drawbacks to make it efficient:

  • For data augmentations on GPU, some CPU/GPU synchronizations cannot be avoided.
  • For data augmentations applied on batch, the randomness is sampled for the whole batch and not each sample.

Torchaug removes these issues and its transforms are meant to be used in place of Torchvision. It is based on the code base of Torchvision and therefore follows the same nomenclature as Torchvision with functional augmentations and transforms class wrappers. However, Torchaug does not support transforms on Pillow images.

More details can be found in the documentation.

To be sure to retrieve the same data augmentations as Torchvision, the components are tested to match Torchvision outputs. We made a speed comparison here.

If you find any unexpected behavior or want to suggest a change please open an issue.

How to use

  1. Install Torchaug.
pip install torchaug
  1. Import data augmentations from the torchaug.transforms package just as for Torchvision.
from torchaug.transforms import (
    RandomColorJitter,
    RandomGaussianBlur,
    SequentialTransform
)


transform = SequentialTransform([
    RandomColorJitter(...),
    RandomGaussianBlur(...)
])

For a complete list of transforms please see the documentation.

How to contribute

Feel free to contribute to this library by making issues and/or pull requests. For each feature you implement, add tests to make sure it works. Also, please update the documentation.

Credits

We would like to thank the authors of Torchvision for generously opening their source code. Portions of Torchaug were originally taken from Torchvision, which is released under the BSD 3-Clause License. Please see their repository and their BSD 3-Clause License for more details.

LICENSE

Torchaug is licensed under the CeCILL-C license.

Metadata

Release files for torchaug 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchaug 0.6.1
File Size Uploaded
torchaug-0.6.1.tar.gz 90.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torchaug 0.6.1
File Interpreter ABI Platform
torchaug-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 210.8 kB

Release files / torchaug-0.6.1.tar.gz

Download URL torchaug-0.6.1.tar.gz
Size 90.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6236b9e6114951aa9310356b080cc3eabb0fcf278208bf2930522586e36d87ec
BLAKE2b-256 checksum
How to use checksums
499f9aea6c240b702c8ce19e24dae69847912e526212c41f01f67a876b51fd42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / torchaug-0.6.1-py3-none-any.whl

Download URL torchaug-0.6.1-py3-none-any.whl
Size 120.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5c19b4efc4e0f433b59d5e6def6957a5a074caa7b9f5b1ff9ef7880ee96b52d
BLAKE2b-256 checksum
How to use checksums
d05a0a803a70bdc26c25132495e8a25b626673fe4c9181bc11f8265c9499a3c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page