A package for augmenting images and videos for computer vision tasks
Project description
CVAugmentor
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:
- no_augmentation
- flip
- zoom
- rotate
- shear
- grayscale
- hue
- saturation
- brightness
- exposure
- blur
- noise
- cutout
- negative
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cvaugmentor-1.1.0.tar.gz.
File metadata
- Download URL: cvaugmentor-1.1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae050fa3987c8cdf6bce0eb67b7d81f6c34ba8778eae9afb96db0a494ca68de0
|
|
| MD5 |
889977e67a86d5ec9fc99ecaa856ec01
|
|
| BLAKE2b-256 |
4c0abe3a0a6bc72ec81c1bcc6567da2e666b7cff9a9eb1b1851bf7da11db385c
|
File details
Details for the file CVAugmentor-1.1.0-py3-none-any.whl.
File metadata
- Download URL: CVAugmentor-1.1.0-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e81018ae8f4d6c2f062fd35ec3ea2fcf222fbc1f5738e01b695e7f3beb00794
|
|
| MD5 |
f3a958e2baaf34520faf182f2bf89c86
|
|
| BLAKE2b-256 |
7da848999aaa91efb259597765fdc3efbef58e91a82281661c626c4776b4e1bc
|