Skip to main content

A toolkit for automated data augmentation

Project description

Augmenter: Advanced Image Augmentation Library

Augmenter is a Python library designed to simplify image augmentation for machine learning and deep learning projects. It provides an easy-to-use interface to apply a variety of augmentation techniques and supports randomized augmentation mixing to generate diverse variations of each image.


Features

  • Augment Entire Datasets: Process all images in a directory, including nested subdirectories, while preserving the folder structure.
  • Extensive Augmentation Techniques: Includes operations like flipping, rotation, blurring, brightness/contrast adjustment, grayscale conversion, noise addition, sharpening, and cropping.
  • Random Augmentation Mixing: Combine random augmentations to create diverse variations of the same image.
  • Customizable Variations: Control the number of augmented variations per image when using mixing.
  • Structured Output: The augmented images are saved in the same directory structure as the original dataset.

Installation

Install Augmenter directly from PyPI:

pip install augmenter

Usage-1

Basic Augmentation

To apply augmentations to all images in a folder, preserving the directory structure, use the following code:

from augment_labeler import Augmenter

augmenter = Augmenter()

# Applying augmentations with mixing enabled and 3 variations per image
augmented_count = augmenter.apply(
    image_dir="./dataset",  # Path to the dataset
    augmentations=[
        "flip", 
        "rotate", 
        "blur", 
        "brightness_contrast", 
        "grayscale", 
        "noise", 
        "sharpen", 
        "crop"
    ],  # List of augmentations to apply
    save_path="./augmented_dataset",  # Path to save augmented images
    mixing=True,  # Enable mixed augmentations
    variations_per_image=3  # Create 3 variations for each image
)

print(f"Total augmented images created: {augmented_count}")

Output Structure

After running the above script, the output will be saved in the augmented_dataset folder, preserving the original folder structure with the added augmentation variations. The directory structure will look like this:

augmented_dataset/
├── class1/
│   ├── img1_mix_1.jpg
│   ├── img1_mix_2.jpg
│   ├── img1_mix_3.jpg
│   ├── img2_mix_1.jpg
│   ├── img2_mix_2.jpg
│   ├── img2_mix_3.jpg
├── class2/
│   ├── img3_mix_1.jpg
│   ├── img3_mix_2.jpg
│   ├── img3_mix_3.jpg
│   ├── img4_mix_1.jpg
│   ├── img4_mix_2.jpg
│   ├── img4_mix_3.jpg
  • Each image is augmented and saved with a _mix_X suffix (where X is the variation number).
  • The folder structure is preserved for each class (e.g., class1/, class2/), making it easy to use the augmented dataset for machine learning.

Usage-2

Basic Augmentation

To apply augmentations to all images in a folder, preserving the directory structure, use the following code:

from augment_labeler import Augmenter

augmenter = Augmenter()
augmented_count = augmenter.apply(
    image_dir="./dataset", 
    augmentations=["flip", "rotate", "blur"], 
    save_path="./augmented_dataset"
)

print(f"Total augmented images created: {augmented_count}")

Output Structure

After running the above script, the output will be saved in the augmented_dataset folder, preserving the original folder structure with the added augmentation variations. The directory structure will look like this:

/your_project/
├── dataset/
│   ├── class1/
│   │   ├── img1.jpg
│   │   ├── img2.jpg
│   ├── class2/
│   │   ├── img3.jpg
│   ├── img4.jpg
├── augmented_dataset/
│   ├── class1/
│   │   ├── img1_flip.jpg
│   │   ├── img1_rotate.jpg
│   │   ├── img1_blur.jpg
│   │   ├── img2_flip.jpg
│   │   ├── img2_rotate.jpg
│   │   ├── img2_blur.jpg
│   ├── class2/
│   │   ├── img3_flip.jpg
│   │   ├── img3_rotate.jpg
│   │   ├── img3_blur.jpg
│   ├── img4_flip.jpg
│   ├── img4_rotate.jpg
│   ├── img4_blur.jpg
  • The folder structure is preserved for each class (e.g., class1/, class2/), making it easy to use the augmented dataset for machine learning.

Supported Augmentations

  • flip: Horizontal flip
  • rotate: Random rotation (up to ±45 degrees)
  • blur: Gaussian blur
  • brightness_contrast: Random brightness and contrast adjustments
  • grayscale: Convert image to grayscale
  • noise: Add Gaussian noise
  • sharpen: Sharpen the image
  • crop: Random resized cropping


Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes and push them to your fork.
  4. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Release Notes

v0.1.0

  • Initial release.
  • Support for multiple augmentations and structured dataset output.
  • Added random augmentation mixing and customizable variations.

Author

Developed by AKM Korishee Apurbo. Feel free to reach out with questions, suggestions, or contributions!

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

augmenter-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: augmenter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for augmenter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9eb846700f9b26d5f2c1b8c771d1cfa149c418defe9bb6888d37be3153f5a713
MD5 331d627aa769692001c2b74238d08c81
BLAKE2b-256 6ba990f8789559dc9a5e6a4923467f6398f9678c14d5cf8663374680ca660ea0

See more details on using hashes here.

Supported by

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