This Python script helps you augment a small dataset of images to create a larger dataset for training machine learning models. It uses the powerful albumentations library to apply various image transformations to enhance your dataset.
-
🖼️ Multiple Augmentation Techniques: Applies various transformations including:
- Horizontal flips
- Random 90° rotations
- Random rotation (±30°)
- Brightness and contrast adjustments
- RGB color shifts
- Blur effects
- Gamma corrections
- Affine transformations (shifting, scaling, rotating)
- And more!
-
📁 Automatic Folder Handling: Creates output directories if they don't exist
-
🔄 Batch Processing: Processes multiple images in one go
-
🖼️ Multiple Image Formats: Supports .jpg, .jpeg, .png (case insensitive)
-
🛠️ Customizable: Easy to modify and extend for different augmentation needs
- Python 3.6+
- Required Python packages (install using
pip install -r requirements.txt):- albumentations
- opencv-python
-
Clone this repository:
git clone [email protected]:Nazmul7989/python-image-augmentation.git cd python-image-augmentation
-
Install the required packages:
pip install -r requirements.txt
- Place your input images in the
./images/input/directory - Run the script:
python main.py
- Find the augmented images in the
./dataset/augmented/directory
You can modify these settings in main.py:
input_folder: Path to your input images (default:'./images/input')output_folder: Where augmented images will be saved (default:'./dataset/augmented')images_to_generate_per_image: Number of augmented versions to create per image (default:10)
.
├── dataset/ # Output folder for augmented images
│ └── augmented/ # Augmented images will be saved here
├── images/ # Input folder for original images
│ └── input/ # Place your original images here
├── main.py # Main augmentation script
├── requirements.txt # Python dependencies
└── README.md # This file
For each input image (e.g., image1.jpg), the script will generate multiple augmented versions (e.g., image1_aug_0.jpg, image1_aug_1.jpg, etc.) in the output folder.
This project is licensed under the terms of the MIT license. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Built with Albumentations for fast and flexible image augmentations
- Uses OpenCV for image processing
Note: This project is designed for general-purpose image augmentation and can be used for various computer vision tasks including but not limited to medical imaging, object detection, and classification tasks.