Package: albumentations
AlbumentationsAlbumentations is a Python library for image augmentation. Image augmentation is used in deep learning and computer vision tasks to increase the quality of trained models. The purpose of image augmentation is to create new training samples from the existing data.Here is an example of how you can apply somepixel-levelaugmentations from Albumentations to create new images from the original one:Why AlbumentationsAlbumentationssupports all common computer vision taskssuch as classification, semantic segmentation, instance segmentation, object detection, and pose estimation.The library providesa simple unified APIto work with all data types: images (RBG-images, grayscale images, multispectral images), segmentation masks, bounding boxes, and keypoints.The library containsmore than 70 different augmentationsto generate new training samples from the existing data.Albumentations isfast. We benchmark each new release to ensure that augmentations provide maximum speed.Itworks with popular deep learning frameworkssuch as PyTorch and TensorFlow. By the way, Albumentations is a part of thePyTorch ecosystem.Written by experts. The authors have experience both working on production computer vision systems and participating in competitive machine learning. Many core team members are Kaggle Masters and Grandmasters.The library iswidely usedin industry, deep learning research, machine learning competitions, and open source projects.Table of contentsAlbumentationsWhy AlbumentationsTable of contentsAuthorsInstallationDocumentationA simple exampleGetting startedI am new to image augmentationI want to use Albumentations for the specific task such as classification or segmentationI want to know how to use Albumentations with deep learning frameworksI want to explore augmentations and see Albumentations in actionWho is using AlbumentationsSee alsoList of augmentationsPixel-level transformsSpatial-level transformsA few more examples of augmentationsSemantic segmentation on the Inria datasetMedical imagingObject detection and semantic segmentation on the Mapillary Vistas datasetKeypoints augmentationBenchmarking resultsContributingCommunity and SupportCommentsCitingAuthorsVladimir I. Iglovikov|Kaggle GrandmasterMikhail Druzhinin|Kaggle ExpertAlex Parinov|Kaggle MasterAlexander Buslaev— Computer Vision Engineer at Mapbox|Kaggle MasterEvegene Khvedchenya— Computer Vision Research Engineer at Piñata Farms|Kaggle GrandmasterInstallationAlbumentations requires Python 3.8 or higher. To install the latest version from PyPI:pipinstall-UalbumentationsOther installation options are described in thedocumentation.DocumentationThe full documentation is available athttps://albumentations.ai/docs/.A simple exampleimportalbumentationsasAimportcv2# Declare an augmentation pipelinetransform=A.Compose([A.RandomCrop(width=256,height=256),A.HorizontalFlip(p=0.5),A.RandomBrightnessContrast(p=0.2),])# Read an image with OpenCV and convert it to the RGB colorspaceimage=cv2.imread("image.jpg")image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)# Augment an imagetransformed=transform(image=image)transformed_image=transformed["image"]Getting startedI am new to image augmentationPlease start with theintroduction articlesabout why image augmentation is important and how it helps to build better models.I want to use Albumentations for the specific task such as classification or segmentationIf you want to use Albumentations for a specific task such as classification, segmentation, or object detection, refer to theset of articlesthat has an in-depth description of this task. We also have alist of exampleson applying Albumentations for different use cases.I want to know how to use Albumentations with deep learning frameworksWe haveexamples of using Albumentationsalong with PyTorch and TensorFlow.I want to explore augmentations and see Albumentations in actionCheck theonline demo of the library. With it, you can apply augmentations to different images and see the result. Also, we have alist of all available augmentations and their targets.Who is using AlbumentationsSee alsoA list of papers that cite Albumentations.A list of teams that were using Albumentations and took high places in machine learning competitions.Open source projects that use Albumentations.List of augmentationsPixel-level transformsPixel-level transforms will change just an input image and will leave any additional targets such as masks, bounding boxes, and keypoints unchanged. The list of pixel-level transforms:AdvancedBlurBlurCLAHEChannelDropoutChannelShuffleColorJitterDefocusDownscaleEmbossEqualizeFDAFancyPCAFromFloatGaussNoiseGaussianBlurGlassBlurHistogramMatchingHueSaturationValueISONoiseImageCompressionInvertImgMedianBlurMotionBlurMultiplicativeNoiseNormalizePixelDistributionAdaptationPosterizeRGBShiftRandomBrightnessContrastRandomFogRandomGammaRandomGravelRandomRainRandomShadowRandomSnowRandomSunFlareRandomToneCurveRingingOvershootSharpenSolarizeSpatterSuperpixelsTemplateTransformToFloatToGrayToRGBToSepiaUnsharpMaskZoomBlurSpatial-level transformsSpatial-level transforms will simultaneously change both an input image as well as additional targets such as masks, bounding boxes, and keypoints. The following table shows which additional targets are supported by each transform.TransformImageMasksBBoxesKeypointsAffine✓✓✓✓BBoxSafeRandomCrop✓✓✓CenterCrop✓✓✓✓CoarseDropout✓✓✓Crop✓✓✓✓CropAndPad✓✓✓✓CropNonEmptyMaskIfExists✓✓✓✓ElasticTransform✓✓✓Flip✓✓✓✓GridDistortion✓✓✓GridDropout✓✓HorizontalFlip✓✓✓✓Lambda✓✓✓✓LongestMaxSize✓✓✓✓MaskDropout✓✓NoOp✓✓✓✓OpticalDistortion✓✓✓PadIfNeeded✓✓✓✓Perspective✓✓✓✓PiecewiseAffine✓✓✓✓PixelDropout✓✓✓✓RandomCrop✓✓✓✓RandomCropFromBorders✓✓✓✓RandomCropNearBBox✓✓✓✓RandomGridShuffle✓✓✓RandomResizedCrop✓✓✓✓RandomRotate90✓✓✓✓RandomScale✓✓✓✓RandomSizedBBoxSafeCrop✓✓✓RandomSizedCrop✓✓✓✓Resize✓✓✓✓Rotate✓✓✓✓SafeRotate✓✓✓✓ShiftScaleRotate✓✓✓✓SmallestMaxSize✓✓✓✓Transpose✓✓✓✓VerticalFlip✓✓✓✓XYMasking✓✓✓A few more examples of augmentationsSemantic segmentation on the Inria datasetMedical imagingObject detection and semantic segmentation on the Mapillary Vistas datasetKeypoints augmentationBenchmarking resultsTo run the benchmark yourself, follow the instructions inbenchmark/README.mdResults for running the benchmark on the first 2000 images from the ImageNet validation set using an Intel(R) Xeon(R) Gold 6140 CPU.
All outputs are converted to a contiguous NumPy array with the np.uint8 data type.
The table shows how many images per second can be processed on a single core; higher is better.albumentations1.1.0imgaug0.4.0torchvision (Pillow-SIMD backend)0.10.1keras2.6.0augmentor0.2.8solt0.1.9HorizontalFlip102202702251787625286798VerticalFlip443821412151438121553659Rotate3892831652860367ShiftScaleRotate66942514629--Brightness276511244112294082335Contrast27671137349-3462341BrightnessContrast2746629190-1891196ShiftRGB27581093-360--ShiftHSV59825959--144Gamma2849-388--933Grayscale5219393723-10821309RandomCrop64163550256250159-4284222260PadToSize5123609-602--3097Resize51210496111066-10411017RandomSizedCrop_64_51232248581660-15982675Posterize2789-----Solarize2761-----Equalize647385--765-Multiply26591129----MultiplyElementwise111200----ColorJitter3517857---Python and library versions: Python 3.9.5 (default, Jun 23 2021, 15:01:51) [GCC 8.3.0], numpy 1.19.5, pillow-simd 7.0.0.post3, opencv-python 4.5.3.56, scikit-image 0.18.3, scipy 1.7.1.ContributingTo create a pull request to the repository, follow the documentation atCONTRIBUTING.mdCommunity and SupportTwitterDiscordCommentsIn some systems, in the multiple GPU regime, PyTorch may deadlock the DataLoader if OpenCV was compiled with OpenCL optimizations. Adding the following two lines before the library import may help. For more detailshttps://github.com/pytorch/pytorch/issues/1355cv2.setNumThreads(0)cv2.ocl.setUseOpenCL(False)CitingIf you find this library useful for your research, please consider citingAlbumentations: Fast and Flexible Image Augmentations:@Article{info11020125,AUTHOR={Buslaev, Alexander and Iglovikov, Vladimir I. and Khvedchenya, Eugene and Parinov, Alex and Druzhinin, Mikhail and Kalinin, Alexandr A.},TITLE={Albumentations: Fast and Flexible Image Augmentations},JOURNAL={Information},VOLUME={11},YEAR={2020},NUMBER={2},ARTICLE-NUMBER={125},URL={https://www.mdpi.com/2078-2489/11/2/125},ISSN={2078-2489},DOI={10.3390/info11020125}}