Skip to main content

CVAugmentor

License PyPI Version tests

CVAugmentorAugmentations

CVAugmentor is a Python package designed for augmenting images and videos, making it easier to enhance and modify visual data for computer vision tasks. It provides a collection of utilities that automate transformations such as flipping, rotation, scaling, color adjustments, and more.

Available augmentations are:

  • Blur
  • Brightness
  • Cutout
  • Exposure
  • Flip
  • Grayscale
  • Hue
  • Negative
  • NoAugmentation
  • Noise
  • Rotate
  • Saturation
  • Shear
  • Zoom

Installation

This package is built with Python 3.12.8.

The simplest way to install it is via pip. Run the following command:

pip install CVAugmentor

Alternatively, you can install it manually by cloning the repository and running the installation. Use the following steps:

git clone git@github.com:AliKHaliliT/CVAugmentor.git  # With SSH
cd CVAugmentor
pip install -r requirements.txt
pip install .

Usage

For a comprehensive guide on how to use the package, please refer to the documentation.

The documentation is kept up-to-date and is automatically generated whenever a change is made to the package through the GitHub Actions workflow.

The provided pipeline should be sufficient for most use cases:

from CVAugmentor import Pipeline


p = Pipeline()

If you require custom functionality, you can also import the augmentations directly:

from CVAugmentor.assets.augmentations._blur import Blur


blur_instance = Blur()

Examples

Single Image Augmentation

from CVAugmentor import Augmentations as aug
from CVAugmentor import Pipeline


## Define the augmentations
augmentations = {
    "blur": aug.Blur(2.5),
    "brightness": aug.Brightness(0.25),
    "cutout": aug.Cutout(max_size=64, max_count=6),
    "expsure": aug.Exposure(0.3),
    "flip": aug.Flip(),
    "grayscale": aug.Grayscale(),
    "hue": aug.Hue(-360),
    "negative": aug.Negative(),
    "no_augmentation": aug.NoAugmentation(),
    "noise": aug.Noise(0.4),
    "rotate": aug.Rotate(),
    "saturation": aug.Saturation(0.5),
    "shear": aug.Shear((0.2, 0.2)),
    "zoom": aug.Zoom(),
}


## Create a Pipeline object
p = Pipeline()

## Augment the image
p.augment(input_path="local_util_resources/samples/images/0.png", 
          output_path="local_util_resources/experiments/single_image/0.png", 
          target="image", 
          process_type="single", 
          mode="sequential", 
          augmentations=augmentations, 
          aug_verbose=True)

Single Video Augmentation

from CVAugmentor import Augmentations as aug
from CVAugmentor import Pipeline


## Define the augmentations
augmentations = {
    "blur": aug.Blur(2.5),
    "brightness": aug.Brightness(0.25),
    "cutout": aug.Cutout(max_size=64, max_count=6),
    "expsure": aug.Exposure(0.3),
    "flip": aug.Flip(),
    "grayscale": aug.Grayscale(),
    "hue": aug.Hue(-360),
    "negative": aug.Negative(),
    "no_augmentation": aug.NoAugmentation(),
    "noise": aug.Noise(0.4),
    "rotate": aug.Rotate(),
    "saturation": aug.Saturation(0.5),
    "shear": aug.Shear((0.2, 0.2)),
    "zoom": aug.Zoom(),
}


## Create a Pipeline object
p = Pipeline()

## Augment the video
p.augment(input_path="local_util_resources/samples/videos/0.mp4", 
          output_path="local_util_resources/experiments/single_video/0.mp4", 
          target="video", 
          process_type="single", 
          mode="singular", 
          augmentations=augmentations, 
          aug_verbose=True)

Augmenting Multiple Images

from CVAugmentor import Augmentations as aug
from CVAugmentor import Pipeline


## Define the augmentations
augmentations = {
    "blur": aug.Blur(),
    "brightness": aug.Brightness(),
    "cutout": aug.Cutout(),
    "expsure": aug.Exposure(),
    "flip": aug.Flip(),
    "grayscale": aug.Grayscale(),
    "hue": aug.Hue(),
    "negative": aug.Negative(),
    "no_augmentation": aug.NoAugmentation(),
    "noise": aug.Noise(),
    "rotate": aug.Rotate(),
    "saturation": aug.Saturation(),
    "shear": aug.Shear(),
    "zoom": aug.Zoom(),
}


## Create a Pipeline object
p = Pipeline()

## Augment the images
p.augment(input_path="local_util_resources/samples/images", 
          output_path="local_util_resources/experiments/multi_image", 
          target="image", 
          process_type="batch", 
          mode="singular", 
          augmentations=augmentations, 
          verbose=True, 
          warn_verbose=True,
          random_state=True)

Augmenting Multiple Videos

from CVAugmentor import Augmentations as aug
from CVAugmentor import Pipeline


## Define the augmentations
augmentations = {
    "blur": aug.Blur(),
    "brightness": aug.Brightness(),
    "cutout": aug.Cutout(),
    "expsure": aug.Exposure(),
    "flip": aug.Flip(),
    "grayscale": aug.Grayscale(),
    "hue": aug.Hue(),
    "negative": aug.Negative(),
    "no_augmentation": aug.NoAugmentation(),
    "noise": aug.Noise(),
    "rotate": aug.Rotate(),
    "saturation": aug.Saturation(),
    "shear": aug.Shear(),
    "zoom": aug.Zoom(),
}


## Create a Pipeline object
p = Pipeline()

## Augment the videos
p.augment(input_path="local_util_resources/samples/videos", 
          output_path="local_util_resources/experiments/multi_video", 
          target="video", 
          process_type="batch", 
          mode="singular", 
          augmentations=augmentations, 
          verbose=True, 
          aug_verbose=True,
          warn_verbose=True,
          random_state=True)

License

This work is under an MIT License.

Metadata

Release files for cvaugmentor 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cvaugmentor 1.1.1
File Size Uploaded
cvaugmentor-1.1.1.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cvaugmentor 1.1.1
File Interpreter ABI Platform
CVAugmentor-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.7 kB

Release files / cvaugmentor-1.1.1.tar.gz

Download URL cvaugmentor-1.1.1.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c57dc74d34b25960b055a780b35c8f95f646d9b522e16bb46aea9672f1fbc733
BLAKE2b-256 checksum
How to use checksums
02f807b631c75202598be0ef92b3a36b6d5bf4b5ddec382b4721ebb007c3f699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / CVAugmentor-1.1.1-py3-none-any.whl

Download URL CVAugmentor-1.1.1-py3-none-any.whl
Size 28.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55a593db3ce5d2c815ec91f52f38e6d8efb6ed2297d34aff96169922d0df3ae6
BLAKE2b-256 checksum
How to use checksums
10635e9ef5aa1586db01dd9d8bbfc46fa13f0cab947a2dd15b2fb11fd292059d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

2.0.0

2 release files

1.1.2

2 release files

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page