Breaking changes
- [`imgaug`](https://github.com/aleju/imgaug) dependency is now optional, and by default, Albumentations won't install it. This change was necessary to prevent simultaneous install of both `opencv-python-headless` and `opencv-python` (you can read more about the problem in [this issue](https://github.com/aleju/imgaug/issues/737)). If you still need `imgaug` as a dependency, you can use the `pip install -U albumentations[imgaug]` command to install Albumentations with `imgaug`.
- Deprecated augmentation `ToTensor` that converts NumPy arrays to PyTorch tensors is completely removed from Albumentations. You will get a `RuntimeError` exception if you try to use it. Please switch to [`ToTensorV2`](https://albumentations.ai/docs/api_reference/pytorch/transforms/#albumentations.pytorch.transforms.ToTensorV2) in your pipelines.
New augmentations
- [`A.RandomToneCurve`](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.RandomToneCurve). See a [notebook](https://nbviewer.jupyter.org/github/aaroswings/RandomToneCurveTests/blob/main/RandomToneCurveTests.ipynb) for examples of this augmentation (#839 by aaroswings)
- [`SafeRotate`](https://albumentations.ai/docs/api_reference/augmentations/geometric/rotate/#albumentations.augmentations.geometric.rotate.SafeRotate). Safely Rotate Images Without Cropping (888 by deleomike)
- [`SomeOf`](https://albumentations.ai/docs/api_reference/core/composition/#albumentations.core.composition.SomeOf) transform that applies N augmentations from a list. Generalizing of [`OneOf`](https://albumentations.ai/docs/api_reference/core/composition/#albumentations.core.composition.OneOf) (889 by henrique)
- We are deprecating imgaug transforms and providing Albumentations' implementations for them.
(786 by KiriLev, 787 by KiriLev, 790, 843, 844, 849, 885, 892)
By default, Albumentations doesn't require `imgaug` as a dependency. But if you need `imgaug`, you can install it along with Albumentations by running `pip install -U albumentations[imgaug]`.
Here is a table of deprecated `imgaug` augmentations and respective augmentations from Albumentations that you should use instead:
| Old deprecated augmentation | New augmentation |
|-----------------------------|------------------|
| [IAACropAndPad](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAACropAndPad) | [CropAndPad](https://albumentations.ai/docs/api_reference/augmentations/crops/transforms/#albumentations.augmentations.crops.transforms.CropAndPad) |
| IAAFliplr | [HorizontalFlip](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.HorizontalFlip) |
| IAAFlipud | [VerticalFlip](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.VerticalFlip) |
| [IAAEmboss](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAAEmboss) | [Emboss](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.Emboss) |
| [IAASharpen](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAASharpen) | [Sharpen](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.Sharpen) |
| [IAAAdditiveGaussianNoise](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAAAdditiveGaussianNoise) | [GaussNoise](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.GaussNoise) |
| [IAAPerspective](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAAPerspective) | [Perspective](https://albumentations.ai/docs/api_reference/augmentations/geometric/transforms/#albumentations.augmentations.geometric.transforms.Perspective) |
| [IAASuperpixels](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAASuperpixels) | [Superpixels](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.Superpixels) |
| [IAAAffine](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAAAffine) | [Affine](https://albumentations.ai/docs/api_reference/augmentations/geometric/transforms/#albumentations.augmentations.geometric.transforms.Affine) |
| [IAAPiecewiseAffine](https://albumentations.ai/docs/api_reference/imgaug/transforms/#albumentations.imgaug.transforms.IAAPiecewiseAffine) | [PiecewiseAffine](https://albumentations.ai/docs/api_reference/augmentations/geometric/transforms/#albumentations.augmentations.geometric.transforms.PiecewiseAffine) |
Major changes
- Serialization logic is updated. Previously, Albumentations used the full classpath to identify an augmentation (e.g. `albumentations.augmentations.transforms.RandomCrop`). With the updated logic, Albumentations will use only the class name for augmentations defined in the library (e.g., `RandomCrop`). For custom augmentations created by users and not distributed with Albumentations, the library will continue to use the full classpath to avoid name collisions (e.g., when a user creates a custom augmentation named RandomCrop and uses it in a pipeline).
This new logic will allow us to refactor the code without breaking serialized augmentation pipelines created using previous versions of Albumentations. This change will also reduce the size of YAML and JSON files with serialized data.
The new serialization logic is backward compatible. You can load serialized augmentation pipelines created in previous versions of Albumentations because Albumentations supports the old format.
Bugfixes
- Fixed a bug that prevented [`A.ReplayCompose`](https://albumentations.ai/docs/examples/replay/) to work with bounding boxes and keypoints correctly. (#748)
- [`A.GlassBlur`](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.GlassBlur) now correctly works with float32 inputs (826)
- [`MultiplicativeNoise`](https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.MultiplicativeNoise) now correctly works with gray images with shape `[h, w, 1]`. (793)
Minor changes
- Code for geometric transforms moved to a standalone module [`albumentations.augmentations.geometric`](https://github.com/albumentations-team/albumentations/tree/master/albumentations/augmentations/geometric). (#784)
- Code for crop transforms moved to a standalone module [`albumentations.augmentations.crops`](https://github.com/albumentations-team/albumentations/tree/master/albumentations/augmentations/crops). (#791)
- CI now runs tests under Python 3.9 as well (830)
- Linters and code formatters for CI and pre-commit hooks are updated to the latest versions (831)
- Logic in `setup.py` that detects existing installations of OpenCV now also looks for `opencv-contrib-python` and `opencv-contrib-python-headless` (837 by agchang-cgl)