# Albumentations

**Albumentations** 是一个用于图像增强的开源 Python 库。图像增强是指对训练图像施加翻转、旋转、亮度调整等保持标签不变的变换，以扩大数据集规模并提升其多样性。该库由亚历山大·布斯莱夫（Alexander Buslaev）、阿列克谢·帕里诺夫（Alex Parinov）、叶夫根尼·赫韦德琴亚（Eugene Khvedchenya）、弗拉基米尔·I·伊格洛维科夫（Vladimir I. Iglovikov）和亚历山大·A·卡利宁（Alexandr A. Kalinin）于 2018 年 9 月推出，定位为一个快速、灵活、包含大量变换操作的库，同时也可作为其他增强库的易用封装<sup>[1](https://arxiv.org/abs/1809.06839)</sup>。该库在 albumentations-team 的 GitHub 组织下开发，其期刊论文发表于《Information》11(2):125<sup>[2](https://github.com/albumentations-team/albumentations)</sup><sup> • </sup><sup>[3](https://www.mdpi.com/2078-2489/11/2/125)</sup>。

| 关键事实 | 详情 |
|---|---|
| 首次发布论文 | 布斯莱夫、帕里诺夫、赫韦德琴亚、伊格洛维科夫和卡利宁于 2018 年 9 月 18 日发布的 arXiv 预印本<sup>[1](https://arxiv.org/abs/1809.06839)</sup> |
| 期刊版本 | 《Information》11(2):125，描述了与 imgaug、Augmentor、SOLT、Keras 和 PyTorch 增强操作的基准对比<sup>[3](https://www.mdpi.com/2078-2489/11/2/125)</sup> |
| 核心设计 | 一次变换调用即可同步更新图像、掩码、边界框、关键点、有向边界框（OBB）、体数据和视频帧，使所有目标保持在同一坐标系中<sup>[4](https://albumentations.ai/docs/1-introduction/)</sup> |
| 流水线优化 | 操作按几何、像素级和独立三类分组；像素级操作合成为查找表，几何操作合成为单个仿射变换矩阵<sup>[5](https://nvblanco.github.io/assets/pdf/conferences/2022_euvip.pdf)</sup> |
| 实测速度（2025 年基准） | 在 macOS arm64 上，albumentations 2.0.4 处理 Brightness 的吞吐量为每秒 11985 ± 455 张 uint8 图像，而 torchvision 0.20.1 为每秒 854 ± 13 张，速度为最快竞品的 5.68 倍<sup>[2](https://github.com/albumentations-team/albumentations)</sup> |
| 多光谱支持 | 支持通道数超过 4 的图像增强，被描述为该库的一项特色功能<sup>[3](https://www.mdpi.com/2078-2489/11/2/125)</sup> |
| 许可 | AlbumentationsX 产品由 Albumentations, LLC（一家特拉华州有限责任公司）授权，提供商业许可选项及贡献者协议<sup>[6](https://albumentations.ai/docs/license/)</sup><sup> • </sup><sup>[7](https://github.com/albumentations-team/AlbumentationsX/blob/main/CLA.md)</sup> |

## 目的与背景

数据增强通过保持输出标签不变的输入变换来增加标注训练集的规模和多样性。在计算机视觉中，图像增强作为一种隐式正则化技术，用于对抗深度卷积神经网络中的过拟合。大多数深度学习框架只实现基本的变换，通常是翻转、旋转、缩放和裁剪的变体及其组合，且现有增强工具的处理速度参差不齐。Albumentations 的诞生正是为了解决这两方面的局限，既提供大量变换操作，又具备更高的吞吐量<sup>[1](https://arxiv.org/abs/1809.06839)</sup>。

该库不是深度学习框架。它在数组层面处理增强，模型代码仍留在 PyTorch、TensorFlow/Keras、JAX 或自定义技术栈中；一种常见的 PyTorch 用法是在 `Dataset` 或 `DataLoader` 的工作进程中运行 Albumentations，在批处理之前对每个样本进行增强<sup>[4](https://albumentations.ai/docs/1-introduction/)</sup>。

## 目标感知增强

该库的核心约定是：一次变换调用即可保持所有数据目标的一致性。当图像被缩放或裁剪时，像素重采样应用于图像，掩码按掩码方式重采样，边界框经过坐标重映射并加以过滤，关键点作为点进行平移，3D 体数据则逐切片或整体处理。亮度、对比度、模糊、噪声和压缩等光度操作改变图像证据，但掩码、边界框和关键点仍保持在同一坐标系中<sup>[8](https://albumentations.ai/docs/2-core-concepts/targets/)</sup>。

变换通过 `Compose` 串联，`Compose` 除每个变换自身的概率 `p` 外，还带有自己的应用概率。边界框需要 `bbox_params`，以便库了解坐标格式、标签字段、裁剪、过滤和可见性规则；关键点需要 `keypoint_params`，以指定点格式、可见性、角度和缩放<sup>[4](https://albumentations.ai/docs/1-introduction/)</sup><sup> • </sup><sup>[8](https://albumentations.ai/docs/2-core-concepts/targets/)</sup>。文档记载的用例包括 Inria 数据集上的语义分割、医学影像、Mapillary Vistas 上的目标检测与分割，以及关键点增强<sup>[2](https://github.com/albumentations-team/albumentations)</sup>。

## 执行流水线

在内部，流水线将用户选择的操作分为三组：几何、像素级和独立。按概率选中的操作被收集起来，像素级变换的组合预先计算为查找表并应用于图像，而无法合成的操作（如去模糊或直方图均衡化）则单独运行。Compose 按顺序应用变换，每个变换使用相应的图像、掩码或坐标操作更新其支持的目标，随后对变换后的数据进行后处理<sup>[5](https://nvblanco.github.io/assets/pdf/conferences/2022_euvip.pdf)</sup>。正是这种合成机制使 Albumentations 能够组合此前只有个别底层库才具备的操作<sup>[3](https://www.mdpi.com/2078-2489/11/2/125)</sup>。

## 性能

2018 年论文的基准测试在 ImageNet 验证集的前 2000 张图像上运行，使用 Intel Xeon Platinum 8168 CPU，将所有输出转换为连续的 `np.uint8` 数组，并报告单核每秒处理的图像数。对比的库包括作为框架无关工具的 imgaug、Augmentor 和 SOLT，以及 Keras 和 PyTorch 的增强操作；在大多数操作上，Albumentations 始终快于所有替代方案<sup>[3](https://www.mdpi.com/2078-2489/11/2/125)</sup>。

该项目维护着一个公开的基准测试仓库。2025 年的一项图像基准测试在 macOS 15.1 arm64、16 核 CPU、Python 3.12.8 环境下运行，使用 2000 张图像，每种变换运行 5 次，将 albumentations 2.0.4 与 augly 1.0.0、imgaug 0.4.0、kornia 0.8.0 和 torchvision 0.20.1 进行对比。单 CPU 线程上 uint8 图像每秒的示例结果：Affine 1445 ± 9 对比 imgaug 的 1328 ± 16（为其他库中最快者的 1.09 倍），AutoContrast 1657 ± 13 对比 kornia 的 541 ± 8（3.06 倍），Blur 7657 ± 114 对比 imgaug 的 5381 ± 125（1.42 倍），Brightness 11985 ± 455 对比 torchvision 的 854 ± 13（5.68 倍），CLAHE 647 ± 4 对比 imgaug 的 555 ± 14（1.17 倍）<sup>[2](https://github.com/albumentations-team/albumentations)</sup>。

一项更新的基准工作比较了来自 AlbumentationsX、Pillow、TorchVision、[Kornia](https://www.edgepedia.org/zh/kornia) 和 NVIDIA DALI 的七条完整 RGB JPEG 到 CUDA 输入流水线，衡量指标为吞吐量和峰值 GPU 内存。其已发布的预印本报告了 759 次测量：57 个选定配方下的 253 个实现–配方组合，每个组合三个随机种子<sup>[9](https://github.com/albumentations-team/benchmark)</sup>。基准文档指出，配方参数已按实际效果手动匹配，输出验证检查形状、布局、数据类型和设备，但不保证像素或增强质量相等，且结果取决于硬件、图像尺寸、批大小和工作进程策略<sup>[9](https://github.com/albumentations-team/benchmark)</sup>。

## 可复现性与调试

流水线支持序列化、重放以及检查采样参数，使增强成为实验定义的一部分，而非隐藏的随机状态<sup>[4](https://albumentations.ai/docs/1-introduction/)</sup>。文档区分了确定性验证预处理与增强验证及压力测试：前者应使用不采样随机参数的变换，如 `Resize`、`CenterCrop` 和 `Normalize`；后者则有意测量模型在指定扰动下的行为。设置随机种子并不会把随机变换变成确定性预处理；带种子的随机流水线在每次调用时仍会采样新的增强<sup>[10](https://albumentations.ai/docs/4-advanced-guides/reproducibility/)</sup>。

## 许可与生态

相关产品 AlbumentationsX 由 Albumentations, LLC（一家特拉华州有限责任公司）授权，该项目在发布商业使用许可选项的同时，还提供贡献者许可协议，授予对受涵盖贡献的永久、全球、免版税的版权许可<sup>[6](https://albumentations.ai/docs/license/)</sup><sup> • </sup><sup>[7](https://github.com/albumentations-team/AlbumentationsX/blob/main/CLA.md)</sup>。团队还开发了 AutoAlbument，一个自动搜索增强策略的研究工具<sup>[3](https://www.mdpi.com/2078-2489/11/2/125)</sup>。

来自项目对比页面的实用建议：对于通用图像、视频、体数据或目标感知增强策略，以及在 PyTorch `Dataset`/`DataLoader` 中于批处理前进行增强，应使用 Albumentations；如果需要在 PyTorch 计算图中进行可微分或 GPU 张量变换，可考虑 Kornia；torchvision 可用于无需额外依赖的小规模纯图像预处理；Pillow 适合图像 I/O 和简单工具，而非充当增强层<sup>[11](https://albumentations.ai/docs/torchvision-kornia2albumentations/)</sup>。

## References

1. [Albumentations: fast and flexible image augmentations (arXiv, 2018)](https://arxiv.org/abs/1809.06839)
2. [albumentations-team/albumentations, GitHub repository and benchmark results](https://github.com/albumentations-team/albumentations)
3. [Buslaev et al., Albumentations: Fast and Flexible Image Augmentations, Information 11(2):125, MDPI](https://www.mdpi.com/2078-2489/11/2/125)
4. [Getting Started with Albumentations, official documentation](https://albumentations.ai/docs/1-introduction/)
5. [Pipeline description of Albumentations operation grouping and composition (2022 EUVIP conference paper)](https://nvblanco.github.io/assets/pdf/conferences/2022_euvip.pdf)
6. [AlbumentationsX License Options, official documentation](https://albumentations.ai/docs/license/)
7. [AlbumentationsX Contributor License Agreement, GitHub](https://github.com/albumentations-team/AlbumentationsX/blob/main/CLA.md)
8. [Working with Multiple Data Targets, official documentation](https://albumentations.ai/docs/2-core-concepts/targets/)
9. [albumentations-team/benchmark, GitHub repository](https://github.com/albumentations-team/benchmark)
10. [Reproducibility in Albumentations, official documentation](https://albumentations.ai/docs/4-advanced-guides/reproducibility/)
11. [Transform Library Comparison Guide, official documentation](https://albumentations.ai/docs/torchvision-kornia2albumentations/)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › 语言与视觉人工智能 › 计算机视觉 › 视觉数据集、软件与社区 › CV软件与工具包

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/albumentations

English original: https://www.edgepedia.org/albumentations
