Skip to main content

Image Augs supports Augmentation for Object Detection , Instance Segmentation and classification tasks.

Project description

Image Augmentations 🚀



GitHub code size in bytes GitHub code size in bytes GitHub Repo stars GitHub followers

This is a augemntation tool for Object Detection , Image classification and Instance Segmentation , it can perform 14 annotations. The important ones are rotation, affine, zooming in and out, noise, and blur. The augmentations were applied to a fraction of the data (40 - 50 percent of the images out of 100 can be augmented).When rotating or zooming in and out, the bounding box coordinates will also change as the image is rotated or zoomed.


Code Starts from here

👩🏼‍💻Create a folder first, inside that folder keep your image annotation folder 👩🏼‍💻


👩🏼‍💻 Create a virtual environment 👩🏼‍💻

pip install virtualenv
#name your environment
python3 -m venv <your env name>

#activate the environment --> for linux user
source <your env name>/bin/activate

#activate the environment  --> for windows user
<your env name>/Source/activate.ps1

Installation (for pip installation) 🚀

pip install image_augs

After installation 🎯


Create a .py script inside your created folder

This Script is for OBJECT DETECTION

#import these modules in your created <scriptname>.py file


from object_detection_new.txt_reader_rect import RectAugmentation

################# image height and width combination  ##################

# first combination --> for custom image size
#  image_height = < custom image size > ; 640
#  image_width = < custom image size > ; 320


# second combination --> keep aspect ratio of the image
#  image_height = 640
#  image_width  = 'keep_aspect_ratio_False'

# Third combination --> keeping original image height and width
#  image_height = 'keep_original_image_height'
#  image_width = 'keep_original_image_width'



annotation_folder = 'your folder'
new_aug_saved_folder = 'new saved folder'
train_split = 0.90
image_H = 640  #check above for height and width setting
image_W = 'keep_aspect_ratio'


rect_aug = RectAugmentation(new_aug_saved_folder)

rect_aug.Image_augmentation(annotation_folder,
                                 
                                train_split=train_split,
                                 image_height= image_H,
                                 image_width= image_W,


                                 blur=False,  blur_f=0.8,

                                 motionBlur= False , motionBlur_f= 0.8 ,

                                 rotate=False, rotate_f = 0.8, 

                                 noise=False, noise_f=0.8,

                                 perspective=False, perspective_f = 0.8,

                                 affine=False, affine_f=0.8,

                                 brightness=False, brightness_f=0.8,
                                    
                                 hue=False, hue_f=0.8,

                                 removesaturation=False, removesaturation_f=0.8,

                                 contrast=False, contrast_f=0.8,

                                 upflip=False, upflip_f=0.8,

                                 shear=False, shear_f=0.8, 

                                 rotate90=False, rotate90_f =0.8,

                                 blur_and_noise=False, blur_and_noise_f=0.8,

                                 image_cutout = False, image_cutout_f=0.8,
                                    
                                 mix_aug= False, mix_aug_f=0.8, 
                                    
                                 temperature_change= False, temperature_change_f=0.8,  # change color temperature from cool to warm color

                                 weather_change=True,weather_change_f=0.8), # add rain , fog , snow in your images
                               
                                

#results will be saved in < your given folder >

This Script is for INSTANCE SEGMENTATION

#import these modules in your created <scriptname>.py file
from instance_seg.json_reader_poly import PolygonAugmentation


################# image height and width combination  ##################

# first combination --> for custom image size
#  image_height = < custom image size > ; 640
#  image_width = < custom image size > ; 320


# second combination --> keep aspect ratio of the image
#  image_height = 640
#  image_width  = 'keep_aspect_ratio_False'

# Third combination --> keeping original image height and width
#  image_height = 'keep_original_image_height'
#  image_width = 'keep_original_image_width'


#### yolo ####
# if yolo False then it will normalize all images and save it as txt , if false augmentations will be saved as json.

annotation_folder = 'your data'
new_aug_saved_folder = 'new saved dataset name'
train_split = 0.70
image_H = 640  #check above for height and width setting
image_W = 'keep_aspect_ratio'
yolo = True


im_aug_helper = PolygonAugmentation(aug_save_folder_name=new_aug_saved_folder,
                                    yolo=yolo)

im_aug_helper.Image_augmentation(annotation_folder,
                                 
                                 train_split=train_split,
                                 image_height= image_H,
                                 image_width= image_W,


                                 blur=True,  blur_f=0.8,

                                 motionBlur= False , motionBlur_f= 0.5,

                                 rotate=True, rotate_f = 0.8, 

                                 noise=True, noise_f=0.6,

                                 perspective=True, perspective_f = 0.6,

                                 affine=True, affine_f=0.6,

                                 brightness=True, brightness_f=0.6,
                                    
                                 hue=True, hue_f=0.6,

                                 removesaturation=True, removesaturation_f=0.6,

                                 contrast=True, contrast_f=0.6,

                                 upflip=True, upflip_f=0.8,

                                 shear=True , shear_f=0.7, 

                                 rotate90=True, rotate90_f =1.0,

                                 blur_and_noise=True, blur_and_noise_f=0.6,

                                 image_cutout = True, image_cutout_f=0.6,
                                    
                                 mix_aug=True, mix_aug_f=0.7,
                                    
                                 temperature_change=True, temperature_change_f=0.5,
                                 
                                 weather_change=True,weather_change_f=0.3)
#results will be saved in < your given folder >
***

This Script is for IMAGE CLASSIFICATION

#import these modules in your created <scriptname>.py file
from classification.classification_combined import ImageAugmentHelper


### PARAMS ###
source_folder = '<source folder>'
aug_saved_folder = '<augmentation saved folder>'
train_split = 0.5
image_height = 512
image_width = 512

classification_aug = ImageAugmentHelper(source_folder=source_folder,
                                        aug_save_folder_name=aug_saved_folder,
                                        train_split=train_split,
                                        height=image_height,
                                        width=image_width)


classification_aug.augmentations(

    save_raw_images=True,

    blur=True, blur_f=1.0,

    noise=True,noise_f=1.0,

    horizontalFlip=True, horizontalFlip_f=1.0,

    brightness=True, brightness_f=1.0,

    contrast=True, contrast_f=1.0,

    hue=True, hue_f=1.0,

    saturation=True, saturation_f=1.0,

    zoom=True, zoom_f=1.0,

    perspective=True, perspective_f=1.0,

    translation=True, translation_f=1.0,

    sharpen=True, sharpen_f=1.0,
    
    randomShadow=True, randomShadow_f=1.0
)

Use github to clone image_augmentations repo 🖥️ Use instanceSeg_aug_script.py / classification_aug_script.py / objectDetection_augScript.py according to your needs.


Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

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

Source Distribution

image_augs-2.4.20.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

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

image_augs-2.4.20-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file image_augs-2.4.20.tar.gz.

File metadata

  • Download URL: image_augs-2.4.20.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for image_augs-2.4.20.tar.gz
Algorithm Hash digest
SHA256 8a9a8b0bbc73feabce251f5c5bb33a0cb05b58c848152562349222508a7be166
MD5 c85ccd17dee5be7f00002c6cd14dad09
BLAKE2b-256 092c8b9192e31aa7f858f861804669a6dddd921cb0e79d9a1f0c15f176105043

See more details on using hashes here.

File details

Details for the file image_augs-2.4.20-py3-none-any.whl.

File metadata

  • Download URL: image_augs-2.4.20-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for image_augs-2.4.20-py3-none-any.whl
Algorithm Hash digest
SHA256 2be3af776442b062274223a3eb127b8c990e9c469f4d97c08846690a2a81e1ae
MD5 8e684ba3c83d5cf322b17c1a4f1473ee
BLAKE2b-256 57f2b8beb76e07df044d6eb3c90dc95ee6106b3b3e3593cb8de876680f9b98b6

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