Skip to main content

An image augmentation library for object detection and image classification tasks.

Project description

augment-auto

A python image augmentation library based on opencv and numpy. It can be used for augmenting images in both image classification and object detection tasks. Many different techniques of augmentation are supported, which can be clustered into three major types - geometric transformations, photometric transformations and kernel-based transformations. Library has support for images with bounding boxes as well.

Installation

Install using pip:

pip install augment-auto

Install from github:

git clone https://github.com/keshavoct98/image-augmentation.git
python setup.py install

Documentation

Complete documentaion - https://augment-auto.readthedocs.io/en/latest/
Demo ipython notebokk - demo.ipynb

Examples

# Geometric Transformations
img = cv2.imread('images/3.jpg')
img_new = crop(img, point1 = (100, 100), point2 = (450, 400))
img_new = rotate(img, angle = 15, keep_resolution = True)
img_new = scale(img, fx = 1.5, fy = 1.5, keep_resolution = False)
img_new = shear(img, shear_val = 0.2, axis = 1)
img_new = translate(img, tx = 50, ty = 60)
# Geometric Transformations with bounding box
img = cv2.imread('images/0.jpeg')
bbox = [581, 274, 699, 321]
img_new, bbox_new = crop(img, point1 = (100, 100), point2 = (650, 400), box = bbox)
img_new, bbox_new = rotate(img, angle = 15, keep_resolution = True, box = bbox)
img_new, bbox_new = scale(img, fx = 1.5, fy = 1.3, keep_resolution = False, box = bbox)
img_new, bbox_new = shear(img, shear_val = 0.2, axis = 0, box = bbox)
img_new, bbox_new = translate(img, tx = 50, ty = 160, box = bbox)
# Photometric Transformations
img = cv2.imread('images/1.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img_new = brightness_contrast(img, alpha = 1.3, beta = 20)            
img_new = brightness_contrast(img, alpha = 0.7, beta = -10)
img_new = colorSpace(img, colorspace = 'hsv')             
img_new = colorSpace(img, colorspace = 'ycrcb')           
img_new = colorSpace(img, colorspace = 'lab')
img_new = addNoise(img, 'gaussian', mean = 0, var = 0.08)
img_new = addNoise(img, 'salt_pepper', sp_ratio = 0.5, noise_amount = 0.1)
img_new = addNoise(img, 'poisson', noise_amount = 0.5)
# Kernel-based Transformations
img = cv2.imread('images/0.jpeg')
bbox = [581, 274, 699, 321]
img_new = randomErase(img, size = (100, 100))            
img_new = randomCropAdd(img, size = (100, 100))
img_new = sharpen(img)
img_new = randomErase(img, size = (60, 40), box = bbox)            
img_new = randomCropAdd(img, size = (60, 40), box = bbox)
img_new = blur(img, 'avg', ksize = (9,9))
img_new = blur(img, 'gaussian', ksize = (9,9), gaussian_sigma = 0)
img_new = blur(img, 'median', median_ksize = 11)

References

  1. https://numpy.org/doc/
  2. https://docs.opencv.org/master/
  3. https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html
  4. https://stackabuse.com/affine-image-transformations-in-python-with-numpy-pillow-and-opencv/
  5. https://cristianpb.github.io/blog/image-rotation-opencv

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

augment_auto-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

augment_auto-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file augment_auto-0.1.0.tar.gz.

File metadata

  • Download URL: augment_auto-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

File hashes

Hashes for augment_auto-0.1.0.tar.gz
Algorithm Hash digest
SHA256 00fd86165026b3fe682238b32ee6707f474af28d17fd975ce47be5e5c9512372
MD5 c4cbae5c1cdb95fe9141dfc73bd1c1c7
BLAKE2b-256 dbfc00818212f1c75dea36037e98a15b8b00c4fac44f0d6e90d7d89169f6a941

See more details on using hashes here.

File details

Details for the file augment_auto-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: augment_auto-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

File hashes

Hashes for augment_auto-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62c958f3b63ba5a4ca73a56034287de379d5600b04b8020d17c5f9ee0ccced79
MD5 42f0bf33fcabc56d97ce4aeecc48ef31
BLAKE2b-256 56452a2e563ea436034a698518096aa813ed23f15709c8cbef4ae3b3971f3a40

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page