The Augmentator module is a versatile image augmentation tool designed to enhance datasets with a variety of transformations. These transformations can be toggled on or off via a configuration file (config.ini) and include customizable parameters for fine-tuning the augmentation process.
The following image transformations are available:
gaussian_blur- Applies a Gaussian blur to the image.random_affine- Performs random affine transformations such as scaling, rotation, and translation.random_crop- Randomly crops the image to a specified size.color_jitter- Adjusts brightness, contrast, saturation, and hue randomly.random_elastic- Applies elastic deformations to the image.dct_reset- Resets discrete cosine transform coefficients based on a probability.dct_pertubation- Perturbs DCT coefficients randomly.dwt_reset- Resets discrete wavelet transform coefficients.dwt_pertubation- Perturbs DWT coefficients randomly.rt_reset- Resets Radon projections randomly.
You can enable or disable any of these transformations by setting their value to true or false in the config.ini file.
The config.ini file allows you to:
- Enable or disable specific transformations.
- Adjust parameters for certain transformations, such as kernel sizes, probabilities, and intensity ranges.
Example config.ini snippet:
[augmentation_techniques]
gaussian_blur = true
random_affine = true
random_crop = true
color_jitter = true
random_elastic = true
dct_reset = true
dct_pertubation = true
dwt_reset = true
dwt_pertubation = true
[gaussian_blur]
kernel_size_x = 25
kernel_size_y = 25
sigma_x = 4.0
sigma_y = 4.0
num_images = 1
[random_affine]
degree_min = -10.0
degree_max = 10.0
translate_x_min = -5.0
translate_x_max = 5.0
translate_y_min = -5.0
translate_y_max = 5.0
scale_min = 0.9
scale_max = 1.1
num_images = 1
[random_crop]
crop_height = 200
crop_width = 200
num_images = 1
[color_jitter]
contrast_min = 1.5
contrast_max = 2
brightness_min = -0.5
brightness_max = 0.5
saturation_min = 0.5
saturation_max = 2
hue_min = -30.0
hue_max = 30.0
num_images = 1
[random_elastic]
alpha = 100.0
sigma = 10.0
num_images = 1
[dct_reset]
probability = 0.1
num_images = 1
[dct_pertubation]
probability = 0.001
num_images = 1
[dwt_reset]
probability = 0.0001
num_images = 1
[dwt_pertubation]
probability = 0.1
num_images = 1
[rt_reset]
probability = 0.001
num_steps = 15000
num_images = 1To install and set up the project, follow these steps:
- Open Julia and navigate to the project directory:
cd("path/to/project")
- Activate the project environment:
using Pkg Pkg.activate(".")
- Install all required dependencies:
Pkg.instantiate()
- Run the tests to ensure everything is set up correctly:
Pkg.test()
To test the module, the examples folder contains a sample dataset located in examples/test_dataset. Start the augmentation process by running the following command:
using Augmentator
dataset_path = "examples/test_dataset" # Specify the dataset path
config_path = "src/config.ini" # Path to your config.ini file
output_path = "examples/augm_dataset" # Path to save augmented images
Augmentator.augment_dataset(dataset_path, config_path, output_path)datasets = [dataset_path, output_path]
merged_dataset = Augmentator.load_and_merge_datasets(datasets, shuffle=true)batch_iterator = Augmentator.batch_iterator(merged_dataset, 2)
for batch in batch_iterator
println("New batch with $(length(batch)) samples.")
endThis module is open-source and free to use under the MIT License.