Albumentations

Latest version: v2.0.4

Safety actively analyzes 707009 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 3 of 8

1.4.17

* Support Our Work
* Transforms
* Core

Support Our Work
1. **Love the library?** You can contribute to its development by becoming a [sponsor for the library](https://github.com/sponsors/albumentations-team). Your support is invaluable, and every contribution makes a difference.
2. **Haven't starred our repo yet?** Show your support with a ⭐! It's just [only one mouse click away](https://github.com/albumentations-team/albumentations).
3. **Got ideas or facing issues?** We'd love to hear from you. Share your thoughts in our [issues](https://github.com/albumentations-team/albumentations/issues) or join the conversation on our [Discord server](https://discord.gg/AmMnDBdzYs)

Transforms
[CoarseDropout](https://explore.albumentations.ai/transform/CoarseDropout)
1. Added Bounding Box support
2. `remove_invisible=False` keeps keypoints
<img width="1224" alt="Screenshot 2024-09-30 at 15 25 53" src="https://github.com/user-attachments/assets/55cd90f4-7c9a-4409-91d3-b0bec69e99f0">

by ternaus

[ElasticTransform]()
Added support for keypoints

<img width="1228" alt="Screenshot 2024-09-30 at 15 29 36" src="https://github.com/user-attachments/assets/7dc62f05-e8b2-4e49-b501-4327761dc4e3">

by ternaus

Core

Added [RandomOrder](https://albumentations.ai/docs/api_reference/full_reference/?h=randomorder#albumentations.core.composition.RandomOrder) Compose

python
Select N transforms to apply. Selected transforms will be called in random order with force_apply=True.
Transforms probabilities will be normalized to one 1, so in this case transforms probabilities works as weights.
This transform is like SomeOf, but transforms are called with random order.
It will not replay random order in ReplayCompose.

1.4.16

- Support Our Work
- UI Tool
- Transforms
- Improvements and Bug Fixes

Support Our Work
1. **Love the library?** You can contribute to its development by becoming a [sponsor for the library](https://github.com/sponsors/albumentations-team). Your support is invaluable, and every contribution makes a difference.
2. **Haven't starred our repo yet?** Show your support with a ⭐! It's just [only one mouse click away](https://github.com/albumentations-team/albumentations).
3. **Got ideas or facing issues?** We'd love to hear from you. Share your thoughts in our [issues](https://github.com/albumentations-team/albumentations/issues) or join the conversation on our [Discord server](https://discord.gg/AmMnDBdzYs)

UI Tool
For visual debug wrote a tool that allows visually inspect effects of augmentations on the image.

You can find it at [https://explore.albumentations.ai/](https://explore.albumentations.ai/)

- Works for all ImageOnly transforms
- Authorized users can upload their own images

it is work in progress. It is not stable and polished yet, but if you have feedback or proposals - just write in the Discord Server mentioned above.

Transforms
- Updated and extended docstrings in all ImageOnly transforms.
- All ImageOnly transforms support both `uint8` and `float32` inputs

RandomSnow
Added `texture` method to [RandomSnow](https://explore.albumentations.ai/transform/RandomSnow)

<img width="1226" alt="Screenshot 2024-09-14 at 19 09 52" src="https://github.com/user-attachments/assets/19a3d0b1-a51c-46c5-b5de-810402f5e489">

RandomSunflare

Added `physics_based` method to [RandomSunFlare](https://explore.albumentations.ai/transform/RandomSunFlare)
<img width="1232" alt="Screenshot 2024-09-14 at 19 10 41" src="https://github.com/user-attachments/assets/89d2c5f7-410e-429c-9636-ddb72f8db600">

Bugfixes and improvements
- Bugfix in albucore dependency. Now every `Albumnetations` version is tailored to a specific `albucore` version. Added pre-commit hook to automatically check it on every commit.
- BugFix in [TextImage](https://explore.albumentations.ai/transform/TextImage) transform, after rewriting bbox processing in a vectorized form, transform was failing.
- As a part of the work to remove scikit-image dependency momincks rewrote bbox_affine in a plain numpy
- Bugfix. It was unexpected, but people use bounding bboxes that are less than 1 pixel. Removed constrant on a minimum bounding box being 1x1
- Bugfix in bounding box filtering. Now if all bounding boxes were filtered return not empty array, but empty array of shape (0, 4)

1.4.15

- Support Our Work
- UI Tool
- Core
- Transforms
- Improvements and Bug Fixes

Support Our Work
1. **Love the library?** You can contribute to its development by becoming a [sponsor for the library](https://github.com/sponsors/albumentations-team). Your support is invaluable, and every contribution makes a difference.
2. **Haven't starred our repo yet?** Show your support with a ⭐! It's just [only one mouse click away](https://github.com/albumentations-team/albumentations).
3. **Got ideas or facing issues?** We'd love to hear from you. Share your thoughts in our [issues](https://github.com/albumentations-team/albumentations/issues) or join the conversation on our [Discord server](https://discord.gg/AmMnDBdzYs)

UI Tool
For visual debug wrote a tool that allows visually inspect effects of augmentations on the image.

You can find it at [https://explore.albumentations.ai/](https://explore.albumentations.ai/)

RIght now supports only ImageOnly transforms, and not all but a subset of them.

it is work in progress. It is not stable and polished yet, but if you have feedback or proposals - just write in the Discord Server mentioned above.

![Screenshot 2024-09-12 at 18 11 49](https://github.com/user-attachments/assets/c135694a-ffd2-478b-ac00-ee8d37a1c476)

Core
Bounding box and keypoint processing was vectorized

- You can pass numpy array to compose and not only list of lists.
- Presumably transforms will work faster, but did not benchmark.

Transforms
Affine
- Reflection padding correctly works In `Affine` and `ShiftScaleRotate`

CLAHE
- Added support for float32 images

Equalize
- Added support for float32 images

FancyPCA
- Added support for float32 images
- Added support for any number of channels

PixelDistributionAdaptation
- Added support for float32
- Added support for anyu number of channels

Flip
Still works, but deprecated. It was a very strange transform, I cannot find use case, where you needed to use it.

It was equivalent to:

python
OneOf([Transpose, VerticalFlip, HorizontalFlip])


Most likely if you needed transform that does not create artifacts, you should look at:

- Natural images => `HorizontalFlip` (Symmetry group has 2 elements, meaning will effectively increase your dataset 2x)
- Images that look natural when you vertically flip them => `VerticalFlip` (Symmetry group has 2 elements, meaning will effectively increase your dataset 2x)
- Images that need to preserve parity, for example texts, but we may expect rotated documents => `RandomRotate90` (Symmetry group has 2 elements, meaning will effectively increase your dataset 4x)
- Images that you can flip and rotate as you wish => `D4` (Symmetry group has 8 elements, meaning will effectively increase your dataset 8x)

ToGray
Now you can define the number of output channels in the resulting gray image. All channels will be the same.

Extended ways one can get grayscale image. Most of them can work with any number of channels as input

- `weighted_average`: Uses a weighted sum of RGB channels `(0.299R + 0.587G + 0.114B)`
Works only with 3-channel images. Provides realistic results based on human perception.
- `from_lab`: Extracts the L channel from the LAB color space.
Works only with 3-channel images. Gives perceptually uniform results.
- `desaturation`: Averages the maximum and minimum values across channels.
Works with any number of channels. Fast but may not preserve perceived brightness well.
- `average`: Simple average of all channels.
Works with any number of channels. Fast but may not give realistic results.
- `max`: Takes the maximum value across all channels.
Works with any number of channels. Tends to produce brighter results.
- `pca`: Applies Principal Component Analysis to reduce channels.
Works with any number of channels. Can preserve more information but is computationally intensive.


SafeRotate
Now uses Affine under the hood.

Improvements and Bug Fixes
- Bugfix in `GridElasticDeform` by 4pygmalion
- Speedups in `to_float` and `from_float`
- Bugfix in PadIfNeeded. Did not work when empty bounding boxes were passed.

1.4.14

- Support Our Work
- Transforms
- Improvements and Bug Fixes

Support Our Work
1. **Love the library?** You can contribute to its development by becoming a [sponsor for the library](https://github.com/sponsors/albumentations-team). Your support is invaluable, and every contribution makes a difference.
2. **Haven't starred our repo yet?** Show your support with a ⭐! It's just [only one mouse click away](https://github.com/albumentations-team/albumentations).
3. **Got ideas or facing issues?** We'd love to hear from you. Share your thoughts in our [issues](https://github.com/albumentations-team/albumentations/issues) or join the conversation on our [Discord server](https://discord.gg/AmMnDBdzYs)

Transforms
Added `GridElasticDeform` transform

![image](https://github.com/user-attachments/assets/574c0b71-33cd-4b8b-a3c3-808326eddd2f)

python
Grid-based Elastic deformation Albumentation implementation

This class applies elastic transformations using a grid-based approach.
The granularity and intensity of the distortions can be controlled using
the dimensions of the overlaying distortion grid and the magnitude parameter.
Larger grid sizes result in finer, less severe distortions.

Args:
num_grid_xy (tuple[int, int]): Number of grid cells along the width and height.
Specified as (grid_width, grid_height). Each value must be greater than 1.
magnitude (int): Maximum pixel-wise displacement for distortion. Must be greater than 0.
interpolation (int): Interpolation method to be used for the image transformation.
Default: cv2.INTER_LINEAR
mask_interpolation (int): Interpolation method to be used for mask transformation.
Default: cv2.INTER_NEAREST
p (float): Probability of applying the transform. Default: 1.0.

Targets:
image, mask

Image types:
uint8, float32

Example:
>>> transform = GridElasticDeform(num_grid_xy=(4, 4), magnitude=10, p=1.0)
>>> result = transform(image=image, mask=mask)
>>> transformed_image, transformed_mask = result['image'], result['mask']

Note:
This transformation is particularly useful for data augmentation in medical imaging
and other domains where elastic deformations can simulate realistic variations.



by 4pygmalion

PadIfNeeded
Now reflection padding correctly with bounding boxes and keypoints

by ternaus

RandomShadow

- Works with any number of channels
- Intensity of the shadow is not hardcoded constant anymore but could be sampled

python
Simulates shadows for the image by reducing the brightness of the image in shadow regions.

Args:
shadow_roi (tuple): region of the image where shadows
will appear (x_min, y_min, x_max, y_max). All values should be in range [0, 1].
num_shadows_limit (tuple): Lower and upper limits for the possible number of shadows.
Default: (1, 2).
shadow_dimension (int): number of edges in the shadow polygons. Default: 5.
shadow_intensity_range (tuple): Range for the shadow intensity.
Should be two float values between 0 and 1. Default: (0.5, 0.5).
p (float): probability of applying the transform. Default: 0.5.

Targets:
image

Image types:
uint8, float32

Reference:
https://github.com/UjjwalSaxena/Automold--Road-Augmentation-Library


by JonasKlotz


Improvements and Bug Fixes
- BugFix in `Affine`. Now `fit_output=True` works correctly with bounding boxes. by ternaus
- BugFix in `ColorJitter`. By maremun
- Speedup in `CoarseDropout`. By thomaoc1
- Check for updates does not use `logger` anymore. by ternaus
- Bugfix in `HistorgramMatching`. Before it output array of ones. Now works as expected. by ternaus

1.4.13

What's Changed
* Updated mixing parameters by ternaus in https://github.com/albumentations-team/albumentations/pull/1859
* Updated TextImage by ternaus in https://github.com/albumentations-team/albumentations/pull/1860
* Fix contigous by ternaus in https://github.com/albumentations-team/albumentations/pull/1862

**Full Changelog**: https://github.com/albumentations-team/albumentations/compare/1.4.12...1.4.13

1.4.12

- Support Our Work
- Transforms
- Core Functionality
- Deprecations
- Improvements and Bug Fixes

Support Our Work
1. **Love the library?** You can contribute to its development by becoming a [sponsor for the library](https://github.com/sponsors/albumentations-team). Your support is invaluable, and every contribution makes a difference.
2. **Haven't starred our repo yet?** Show your support with a ⭐! It's just [only one mouse click away](https://github.com/albumentations-team/albumentations).
3. **Got ideas or facing issues?** We'd love to hear from you. Share your thoughts in our [issues](https://github.com/albumentations-team/albumentations/issues) or join the conversation on our [Discord server](https://discord.gg/AmMnDBdzYs)

Transforms
Added TextImage transform

Allows adding text on top of images. Works with `np,unit8` and `np.float32` images with any number of channels.

Additional functionalities:
- Insert random stopwords
- Delete random words
- Swap word order

[Example notebook](https://albumentations.ai/docs/examples/example_textimage/)

![image](https://github.com/user-attachments/assets/ab59dcbf-8198-4179-88f6-403a092b4ed8)

Core functionality
Added `images` target

You can now apply the same transform to a list of images of the same shape, not just one image.

Use cases:
- **Video:** Split video into frames and apply the transform.
- **Slices of 3D volumes:** For example, in medical imaging.

python
import albumentations as A

transform = A.Compose([A.Affine(p=1)])

transformed = transform(images=<list of images>)

transformed_images = transformed["images"]


**Note:**
You can apply the same transform to any number of images, masks, bounding boxes, and sets of keypoints using the additional_targets functionality [notebook with examples](https://albumentations.ai/docs/examples/example_multi_target/)

Contributors ternaus, ayasyrev

`get_params_dependent_on data`

Relevant for those who build custom transforms.

Old way
python
property
def targets_as_params(self) -> list[str]:
return <list of targets>

def get_params_dependent_on_targets(self, params: dict[str, Any]) -> dict[str, np.ndarray]:
image = params["image"]
....


New way
python
def get_params_dependent_on_data(self, params: dict[str, Any], data: dict[str, Any]) -> dict[str, np.ndarray]:
image = data["image"]


Contributor ayasyrev

Added `shape` to params
Old way:
python
def get_params_dependent_on_targets(self, params: dict[str, Any]) -> dict[str, np.ndarray]:
image = params["image"]
shape = image.shape


New way:
python
def get_params_dependent_on_data(self, params: dict[str, Any], data: dict[str, Any]) -> dict[str, np.ndarray]:
shape = params["shape"]

Contributor ayasyrev

Deprecations
Elastic Transform
Deprecated parameter `alpha_affine` in `ElasticTransform`. To have Affine effects on your image, use the `Affine` transform.

Contributor ternaus

Improvements and Bug Fixes
- Removed dependency on scikit-learn. Contributor: ternaus
- Added instructions on how to disable the new version availability message. Contributor: ternaus
- Bugfix in constant padding with nonzero values in CropAndPad, Affine, PadIfNeeded, and Rotate. Contributor: ternaus

Page 3 of 8

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.