Data augmentation Module
Set of functions used to perform data augmentation on images and their assosiated .mat files
- Crowd_counting.augmentation.Horizontal_Flip(img_paths, GT_paths, img_format='jpg')[source]
Flip a list of images horizontally and change the .mat file assosiated with it, save the new images and ground_truth in the specified directory
- Parameters
img_paths (list) – list of paths to the images to be augmented, as generated by the dir_to_list function
GT_paths (list) – list of paths to the Grount truth corresponding to the images to be augmented, as generated by the dir_to_list function
img_format – the format of the images, can only take the values ‘png’ and ‘jpg’
- Crowd_counting.augmentation.brightness_variation(img_paths, GT_paths, img_format='jpg')[source]
Change the brightness of list of images, save the new images and ground_truth in the specified directory
- Parameters
img_paths (list) – list of paths to the images to be augmented, as generated by the dir_to_list function
GT_paths (list) – list of paths to the Grount truth corresponding to the images to be augmented, as generated by the dir_to_list function
img_format – the format of the images, can only take the values ‘png’ and ‘jpg’
- Crowd_counting.augmentation.dir_to_list(img_dir, prefix=('IMG', 'GT_IMG'), img_format='jpg')[source]
Create lists of paths to the ground truth and images, as to be used for image augmentation, ground truth generation and model training. For the list to be created correctly, the directory should have the following form :
Project
+–images
all images
+–ground_truth
all .mat files
- Parameters
img_dir (str) – path to the directory where the images are stored
prefix – tuple containing two strings if the name of the images and ground_truth files are different (eg : GT_IMG_3.mat is the ground_truth file corresponding to IMG_3.png, then prefix = (‘IMG’,’GT_IMG’))
img_format – the format of the images, can only take the values ‘png’ and ‘jpg’
- Returns
2 lists: the first one contain the paths to the images, the second one contain the paths to the associated ground truths (the Ground truth at index i correspond to the image at index i in the ifrst list)
- Crowd_counting.augmentation.full_augment(img_paths, GT_paths, img_format='jpg')[source]
Perform the three different transformations on a set of images, save the new images and ground_truth in the specified directory
- Parameters
img_paths (list) – list of paths to the images to be augmented, as generated by the dir_to_list function
GT_paths (list) – list of paths to the Grount truth corresponding to the images to be augmented, as generated by the dir_to_list function
img_format – the format of the images, can only take the values ‘png’ and ‘jpg’
- Crowd_counting.augmentation.reverse_and_bright(img_paths, GT_paths, img_format='jpg')[source]
Change the brightness of list of images and flip them horizontally, save the new images and ground_truth in the specified directory
- Parameters
img_paths (list) – list of paths to the images to be augmented, as generated by the dir_to_list function
GT_paths (list) – list of paths to the Grount truth corresponding to the images to be augmented, as generated by the dir_to_list function
img_format – the format of the images, can only take the values ‘png’ and ‘jpg’