Mask creation for segmentation tasks and Image augmentation pipeline with imaug and Keras's ImageDataGenerator
This program helps the user to create custom segmentation maps
- BREAK_LIMIT - Program exits after defined number of images for convenience of the user as it runs for loop for the images in that range. Default is 10.
- DATASET_PATH = Path to the Dataset
- MASK_OUTPUT_PATH = Path to save the created mask
- MASK_INV = Path to save the color image mask
- Opencv package - cv2
- Numpy package - numpy
Make sure you have created directories to save the mask and mask_inv and "dataset" folder must contain images with name as numbers starting from 1,2,3...
- r - Mask the image
- SPACE - Reset the inpainting mask
- ESC - Skip current image
- z - Exit program
Make sure that you satisfied the Prerequisite
- Images from the dataset folder will start appearing one at a time.
- Select the region to mask using mouse.
- Press "r" if the free hand marking is appropriate.
- Press "space" to reset the image or ESC to skip the current image or Z to exit the program.
- After pressing "r" your masked region will be displayed in color to check the correctness of your masking.
- Press "y" if satisfied and this will write the mask image to the specified directory.
- Press any other button to redo the masking process.
Exception Handling is in place for a MouseCallbackError which exists in pip installation of opencv but fixed in apt installed opencv, still not sure why it exists. If you haven't installed opencv yet then i would advise to install using this command for ubuntu users "sudo apt install libopencv-dev python3-opencv" It's okay if you have pip installed version that's why the exception handling is in place. Happy Masking!
- IMG_PATH - Path to the dataset directory of images
- MASK_PATH - Path to the dataset of masks of the images
- OUTPUT_IMAGE_PATH - Path to write the augmented images
- OUTPUT_MASK_PATH - Path to write the augmented mask images
- AUG_NUM - Number of augmentation to be done per image
- TOTAL_IMGS - Total images in the directory, will be helpful for tqdm to track the progress
- paths1 and paths2 image extension must be the extension in your dataset for example ".jpg" or ".png".
- Affine Transformation with rotation and shearing
- Coarse Dropout
- Guassian Noise only for image
imgaug library has much more heavy augmentation operations and more sophiticated functions for various necessities.imguag documentation