Package: aug-tool
AUG-TOOL: Image Augmentation Tool for Machine Learning ProjectsAug Tool is a Python library available on PyPI that simplifies image data augmentation for machine learning tasks, compatible with TensorFlow, PyTorch, and the YOLO library.Installationpipinstallaug-toolTo install "aug-tool", you can use pip, the Python package manager. Open a terminal or command prompt and run the following command:FeaturesSupports various image  augmentation techniques suitable for real environment conditions, such as adding noise, scaling, shifting, and more.Provides convenient integration with popular machine learning libraries such asTensorFlow,Keras,PyTorch, etc.Allows augmentation of both images and their annotation files in formats such as XML, or TXT.Customizable augmentation parameters, including rotation angle, scaling factor, flipping direction, and more.Output examplesLabeled dataWith aug toolExample 1Example 2Example 3Example 4DocumentationSimple usage:fromaug_toolimportAugmentation# Specify the input parametersopen_file_name=r"C:\Users\user.name\Desktop\datas\orginal"#Path to the data foldersave_file_name=r"C:\Users\user.name\Desktop\datas\augmented"#Path to the data foldernumber_of_aug=2# Number of augmented data to generate# Apply data augmentation using aug-toolAugmentation(open_data_path=open_file_name,save_file_name=save_file_name,number_of_aug=number_of_aug,x_shift=15,y_shift=15)# Continue with further processing or analysisPackage Structure Diagram:src/#root file└──aug_tool/#main package├──__init__.py├──dataOpener/#sub package1│├──__init__.py│├──dataOp.py│├──imgOp.py│├──annOp.py│├──xmlOp.py│└──txtOp.py├──dataAugmentor/#sub package2│├──__init__.py│├──dataAug.py│├──imgAug.py│├──annAug.py│├──xmlAug.py│└──txtAug.py├──dataSaver/#sub package3│├──__init__.py│├──dataSav.py│├──imgSav.py│├──annSav.pys│├──xmlSav.py│└──txtSav.py└──augmentation.pyClass Diagram:Augmentation Class Initialization:classAugmentation(object):def__init__(self,open_data_path:str,save_file_name:str,number_of_aug:int,x_shift:int,y_shift:int)->None:"""This is an initialization function that takes in parameters for data augmentation and saves theaugmented data and annotations to a specified file path.:param open_data_path: The path to the directory containing the original data to be augmented:type open_data_path: str:param save_file_name: The name of the folder where the augmented data will be saved:type save_file_name: str:param number_of_aug: The number of times the image and its corresponding annotation will beaugmented:type number_of_aug: int:param x_shift: The amount of horizontal shift to apply during image augmentation:type x_shift: int:param y_shift: y_shift is a parameter that determines the maximum number of pixels by which animage can be shifted vertically during data augmentation:type y_shift: int"""The__init__method of the augmentation class performs the initialization and processing steps. This process can be divided into three parts:Part 1: File and Folder CreationIn the first part, the method creates the necessary file names and initializes the folder structure for storing the augmented images. This ensures a well-organized output for the augmented data.# It creates a folder to save insideself.create_dest_folder(self.target_file_name)# All the data in the file is taken and augmented in a loopfordata_pathinself.create_list_of_data(open_data_path=open_data_path):# The image and label file with the same name as image is opened onceimage=self.label_factory(data_path[:-4])label=self.image_factory(data_path)# The augmentation process is performed as much as the `number_of_aug` value  from the userfornuminrange(number_of_aug):# The name of new file that will be augmented is createddata_name=data_path.split("\\")[-1][:-4]+"_aug"+str(num+1))Here, Theself.create_dest_foldermethod is responsible for creating the output folder if it doesn't already exist.self.create_list_of_datastores the path of the files which will be augmented . The loop iterates over the files in theself.create_list_of_datalist and obtains the paths to the corresponding image and label files. Theself.label_factoryandself.image_factorymethods are responsible for opening the image and label files, respectively.Part 2: Image Augmentation ProcessingThe second part of the__init__method performs the actual augmentation processing of images. Within a nested loop, the augmentation techniques are applied to the image to generate multiple augmented versions of the data.# The augmented image is created acording values that given usersaug_image=dataAugmentor.ImgAug(image=image,x_shift=x_shift,y_shift=y_shift).image_aug# The augmented image is saved on target filedataSaver.ImgSav(target_file_path=self.target_file_name,img_aug=aug_image,data_name=data_name)Part 3: Label Augmentation ProcessingThe third part of the__init__method performs the actual augmentation processing of labels. Within a nested loop, the augmentation techniques are applied to the label data to generate multiple augmented versions of the data.# If the extension of the read label file is '.xml', it is processed hereifself.ann.ext==".xml":ann_aug=dataAugmentor.XmlAug(name=data_name,annotate=label.data,x_shift=x_shift,y_shift=y_shift)dataSaver.XmlSav(target_file_path=self.target_file_name,ann_aug=ann_aug.annotate,data_name=data_name)# If the extension of the read label file is '.txt', it is processed hereelifself.ann.ext==".txt":ann_aug=dataAugmentor.TxtAug(annotate=label.data,x_shift=x_shift,y_shift=y_shift,width=aug_image.width,height=aug_image.height).aug_anotatedataSaver.TxtSav(target_file_path=self.target_file_name,ann_aug=ann_aug,data_name=data_name)LicenseThis project is licensed under the MIT License. You are free to use, modify, and distribute this library in accordance with the terms specified in the license.SupportIf you have any questions, suggestions, or need support, feel free to reach out tohakanaktas4541@gmail.com