kandi background
Explore Kits

albumentations | Fast image augmentation library | Computer Vision library

 by   albumentations-team Python Version: 1.1.0 License: MIT

 by   albumentations-team Python Version: 1.1.0 License: MIT

Download this library from

kandi X-RAY | albumentations Summary

albumentations is a Python library typically used in Institutions, Learning, Education, Artificial Intelligence, Computer Vision, Deep Learning, Tensorflow applications. albumentations has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install albumentations' or download it from GitHub, PyPI.
Albumentations 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.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • albumentations has a highly active ecosystem.
  • It has 9761 star(s) with 1257 fork(s). There are 125 watchers for this library.
  • There were 1 major release(s) in the last 12 months.
  • There are 228 open issues and 344 have been closed. On average issues are closed in 45 days. There are 41 open pull requests and 0 closed requests.
  • It has a negative sentiment in the developer community.
  • The latest version of albumentations is 1.1.0
albumentations Support
Best in #Computer Vision
Average in #Computer Vision
albumentations Support
Best in #Computer Vision
Average in #Computer Vision

quality kandi Quality

  • albumentations has 0 bugs and 0 code smells.
albumentations Quality
Best in #Computer Vision
Average in #Computer Vision
albumentations Quality
Best in #Computer Vision
Average in #Computer Vision

securitySecurity

  • albumentations has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • albumentations code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
albumentations Security
Best in #Computer Vision
Average in #Computer Vision
albumentations Security
Best in #Computer Vision
Average in #Computer Vision

license License

  • albumentations is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
albumentations License
Best in #Computer Vision
Average in #Computer Vision
albumentations License
Best in #Computer Vision
Average in #Computer Vision

buildReuse

  • albumentations releases are available to install and integrate.
  • Deployable package is available in PyPI.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • albumentations saves you 4443 person hours of effort in developing the same functionality from scratch.
  • It has 12056 lines of code, 1135 functions and 52 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
albumentations Reuse
Best in #Computer Vision
Average in #Computer Vision
albumentations Reuse
Best in #Computer Vision
Average in #Computer Vision
Top functions reviewed by kandi - BETA

kandi has reviewed albumentations and discovered the below as its top functions. This is intended to give you an instant insight into albumentations implemented functionality, and help decide if they suit your requirements.

  • Transform an image .
  • Generate a list of tiles from a distance map .
  • Returns parameters dependent on the image .
  • Transform an image using elastic transformation .
  • Auxiliary function to transform an image .
  • Add rain .
  • Distortion of an image .
  • Convert bbox to albumentations .
  • Main function .
  • Compute equalize of image .

albumentations Key Features

Fast image augmentation library and an easy-to-use wrapper around other libraries. Documentation: https://albumentations.ai/docs/ Paper about the library: https://www.mdpi.com/2078-2489/11/2/125

Installation

copy iconCopydownload iconDownload
pip install -U albumentations

A simple example

copy iconCopydownload iconDownload
import albumentations as A
import cv2

# Declare an augmentation pipeline
transform = 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 colorspace
image = cv2.imread("image.jpg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Augment an image
transformed = transform(image=image)
transformed_image = transformed["image"]

Comments

copy iconCopydownload iconDownload
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)

Citing

copy iconCopydownload iconDownload
@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}
}

Colab: (0) UNIMPLEMENTED: DNN library is not found

copy iconCopydownload iconDownload
!pip install tensorflow==2.7.0
-----------------------
'tensorflow==2.7.0',
'tf-models-official==2.7.0',
'tensorflow_io==0.23.1',

How resize dataset label in albumentations label to work with tensorflow image_dataset_from_directory function?

copy iconCopydownload iconDownload
def set_shapes(img, label, img_shape=(128,128,3)):
  img.set_shape(img_shape)
  label.set_shape([1,])
  return img, label

colab notebook in Chapter 3 of Underactuated Robotics is not working

copy iconCopydownload iconDownload
!pip install underactuated==2022.01.03

How to make conda use its own gcc version?

copy iconCopydownload iconDownload
# system gcc
which gcc && gcc --version
# /usr/bin/gcc
# gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

# creating a conda env with gcc
conda create -n gcc gcc
# activate the environment
conda activating gcc
which gcc && gcc --version
# /opt/conda/envs/gcc/bin/gcc
# gcc (GCC) 11.2.0
# packages in environment at /opt/conda/envs/gcc:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
binutils_impl_linux-64    2.36.1               h193b22a_2    conda-forge
gcc                       11.2.0               h702ea55_2    conda-forge
gcc_impl_linux-64         11.2.0              h82a94d6_11    conda-forge
kernel-headers_linux-64   2.6.32              he073ed8_15    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libgcc-devel_linux-64     11.2.0              h0952999_11    conda-forge
libgcc-ng                 11.2.0              h1d223b6_11    conda-forge
libgomp                   11.2.0              h1d223b6_11    conda-forge
libsanitizer              11.2.0              he4da1e4_11    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_11    conda-forge
sysroot_linux-64          2.12                he073ed8_15    conda-forge
-----------------------
# system gcc
which gcc && gcc --version
# /usr/bin/gcc
# gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

# creating a conda env with gcc
conda create -n gcc gcc
# activate the environment
conda activating gcc
which gcc && gcc --version
# /opt/conda/envs/gcc/bin/gcc
# gcc (GCC) 11.2.0
# packages in environment at /opt/conda/envs/gcc:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
binutils_impl_linux-64    2.36.1               h193b22a_2    conda-forge
gcc                       11.2.0               h702ea55_2    conda-forge
gcc_impl_linux-64         11.2.0              h82a94d6_11    conda-forge
kernel-headers_linux-64   2.6.32              he073ed8_15    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libgcc-devel_linux-64     11.2.0              h0952999_11    conda-forge
libgcc-ng                 11.2.0              h1d223b6_11    conda-forge
libgomp                   11.2.0              h1d223b6_11    conda-forge
libsanitizer              11.2.0              he4da1e4_11    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_11    conda-forge
sysroot_linux-64          2.12                he073ed8_15    conda-forge
-----------------------
ln -s /home/envs/segmentation_base/bin/x86_64-conda_cos6-linux-gnu-cc gcc
ln -s /home/envs/segmentation_base/bin/x86_64-conda_cos6-linux-gnu-cpp g++

Multipoint(df['geometry']) key error from dataframe but key exist. KeyError: 13 geopandas

copy iconCopydownload iconDownload
# https://www.kaggle.com/new-york-state/nys-nyc-transit-subway-entrance-and-exit-data
import kaggle.cli
import sys, requests, urllib
import pandas as pd
from pathlib import Path
from zipfile import ZipFile

# fmt: off
# download data set
url = "https://www.kaggle.com/new-york-state/nys-nyc-transit-subway-entrance-and-exit-data"
sys.argv = [sys.argv[0]] + f"datasets download {urllib.parse.urlparse(url).path[1:]}".split(" ")
kaggle.cli.main()
zfile = ZipFile(f'{urllib.parse.urlparse(url).path.split("/")[-1]}.zip')
dfs = {f.filename: pd.read_csv(zfile.open(f)) for f in zfile.infolist() if Path(f.filename).suffix in [".csv"]}
# fmt: on

df_subway = dfs['nyc-transit-subway-entrance-and-exit-data.csv']

from shapely.geometry import Point, MultiPoint
from shapely.ops import nearest_points
import geopandas as gpd

geometry = [Point(xy) for xy in zip(df_subway['Station Longitude'], df_subway['Station Latitude'])]

# Coordinate reference system :
crs = {'init': 'EPSG:4326'}

# Creating a Geographic data frame 
gdf_subway_entrance_geometry = gpd.GeoDataFrame(df_subway, crs=crs, geometry=geometry).to_crs('EPSG:5234')
gdf_subway_entrance_geometry

df_yes_entry = gdf_subway_entrance_geometry
df_yes_entry = gdf_subway_entrance_geometry[gdf_subway_entrance_geometry.Entry=='YES']
df_yes_entry

# randomly select a point....
gpdPoint = gdf_subway_entrance_geometry.sample(1).geometry.tolist()[0]
pts = MultiPoint(df_yes_entry['geometry'].values) # does not work with a geopandas series, works with a numpy array
pt = Point(gpdPoint.x, gpdPoint.y)
#[o.wkt for o in nearest_points(pt, pts)]
for o in nearest_points(pt, pts):
  print(o)

using ImageFolder with albumentations in pytorch

copy iconCopydownload iconDownload
trainset = datasets.ImageFolder(traindir,transform=Transforms(transforms=A.Compose([A.Resize(32 , 32), ToTensorV2()]))

ValueError: x_max is less than or equal to x_min for bbox

copy iconCopydownload iconDownload
pix_w = int(bb[2]*img_w)
pix_h = int(bb[3]*img_w)
np.testing.assert_equal(np.all([pix_w>0,pix_h>0]), True)

recursive Instantiating of objects- hydra

copy iconCopydownload iconDownload
Traceback (most recent call last):
  File "1.py", line 30, in <module>
    print(hydra.utils.instantiate(conf.compose))
  File "/home/omry/dev/hydra/hydra/utils.py", line 95, in instantiate
    target = _get_target_type(config, kwargs)
  File "/home/omry/dev/hydra/hydra/_internal/utils.py", line 640, in _get_target_type
    raise InstantiationException("Unable to determine target")

TypeError: slice indices must be integers or None or have an __index__ method (Albumentations/NumPy)

copy iconCopydownload iconDownload
A.RandomCrop(p=1.0, width=img.shape[0] / 2, height=img.shape[1] / 2)
A.RandomCrop(p=1.0, width=int(img.shape[0] / 2), height=int(img.shape[1] / 2))
A.RandomCrop(p=1.0, width=img.shape[0] // 2, height=img.shape[1] // 2)
-----------------------
A.RandomCrop(p=1.0, width=img.shape[0] / 2, height=img.shape[1] / 2)
A.RandomCrop(p=1.0, width=int(img.shape[0] / 2), height=int(img.shape[1] / 2))
A.RandomCrop(p=1.0, width=img.shape[0] // 2, height=img.shape[1] // 2)
-----------------------
A.RandomCrop(p=1.0, width=img.shape[0] / 2, height=img.shape[1] / 2)
A.RandomCrop(p=1.0, width=int(img.shape[0] / 2), height=int(img.shape[1] / 2))
A.RandomCrop(p=1.0, width=img.shape[0] // 2, height=img.shape[1] // 2)

module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'

copy iconCopydownload iconDownload
!pip install -U -q segmentation-models
!pip install -q tensorflow==2.1
!pip install -q keras==2.3.1
!pip install -q tensorflow-estimator==2.1.

## Imports libs
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
os.environ["SM_FRAMEWORK"] = "tf.keras"

from tensorflow import keras
import segmentation_models as sm
|████████████████████████████████| 51kB 3.3MB/s 
|████████████████████████████████| 421.8MB 42kB/s 
|████████████████████████████████| 450kB 35.7MB/s 
|████████████████████████████████| 3.9MB 33.6MB/s 
Building wheel for gast (setup.py) ... done
ERROR: tensorflow-probability 0.12.1 has requirement gast>=0.3.2, 
but you'll have gast 0.2.2 which is incompatible.
|████████████████████████████████| 378kB 2.1MB/s 
Segmentation Models: using `tf.keras` framework.
-----------------------
!pip install -U -q segmentation-models
!pip install -q tensorflow==2.1
!pip install -q keras==2.3.1
!pip install -q tensorflow-estimator==2.1.

## Imports libs
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
os.environ["SM_FRAMEWORK"] = "tf.keras"

from tensorflow import keras
import segmentation_models as sm
|████████████████████████████████| 51kB 3.3MB/s 
|████████████████████████████████| 421.8MB 42kB/s 
|████████████████████████████████| 450kB 35.7MB/s 
|████████████████████████████████| 3.9MB 33.6MB/s 
Building wheel for gast (setup.py) ... done
ERROR: tensorflow-probability 0.12.1 has requirement gast>=0.3.2, 
but you'll have gast 0.2.2 which is incompatible.
|████████████████████████████████| 378kB 2.1MB/s 
Segmentation Models: using `tf.keras` framework.

Community Discussions

Trending Discussions on albumentations
  • Image augmentation on deep learning training data
  • Normalization before and after Albumentations augmentations?
  • Colab: (0) UNIMPLEMENTED: DNN library is not found
  • How resize dataset label in albumentations label to work with tensorflow image_dataset_from_directory function?
  • colab notebook in Chapter 3 of Underactuated Robotics is not working
  • How to make conda use its own gcc version?
  • Augmentation using Albumentations in Pytorch OD
  • Multipoint(df['geometry']) key error from dataframe but key exist. KeyError: 13 geopandas
  • pytorch model predicts fixed label when it exports to onnx
  • using ImageFolder with albumentations in pytorch
Trending Discussions on albumentations

QUESTION

Image augmentation on deep learning training data

Asked 2022-Mar-15 at 09:41

I have a question about mean and standard deviation in image augmentation.

Are the two parameters recommended to be filled in?

If so, how could I know the number? Do I have to iterate through the data, also each channel of image, before the train to get it?

import albumentations as A
train_transform = A.Compose(
        [
            A.Resize(height=IMAGE_HEIGHT, width=IMAGE_WIDTH),
            A.ColorJitter(brightness=0.3, hue=0.3, p=0.3),
            A.Rotate(limit=5, p=1.0),
            # A.HorizontalFlip(p=0.3),
            # A.VerticalFlip(p=0.2),
            A.Normalize(
                mean=[0.0, 0.0, 0.0],# <-----------this parameter
                std=[1.0, 1.0, 1.0],# <-----------this parameter
                max_pixel_value=255.0,
            ),
            ToTensorV2(),
        ],
    )

ANSWER

Answered 2022-Mar-14 at 22:43

Yes it is strongly recommended to normalize your images in most of the cases, obviously you will face some situations that does not require normalization. The reason is to keep the values in a certain range. The output of the network, even if the network is 'big', is strongly influenced by the input data range. If you keep your input range out of control, your predictions will drastically change from one to another. Thus, the gradient would be out of control too and might make your training unefficient. I invite you to read this and that answers to have more details about the 'why' behind normalization and have a deeper understanding of the behaviours.

It is quite common to normalize images with imagenet mean & standard deviation : mean = [0.485, 0.456, 0.406], std = [0.229, 0.224, 0.225]. Of course you could also consider, if your dataset is enough realistic, in a production context, to use its own mean and std instead of imagenet's.

Finally keep in mind those values since, once your model will be trained, you will still need to normalize any new image to achieve a good accuracy with your future inferences.

Source https://stackoverflow.com/questions/71472904

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install albumentations

Albumentations requires Python 3.6 or higher. To install the latest version from PyPI:. Other installation options are described in the documentation.

Support

The full documentation is available at https://albumentations.ai/docs/.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Reuse Pre-built Kits with albumentations
Compare Computer Vision Libraries with Highest Support
Compare Computer Vision Libraries with Highest Security
Compare Computer Vision Libraries with Permissive License
Compare Computer Vision Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.