ida_lib.image_augmentation package¶
Submodules¶
ida_lib.image_augmentation.augment_to_disk module¶
-
class
ida_lib.image_augmentation.augment_to_disk.
AugmentToDisk
(dataset: torch.utils.data.dataset.Dataset, samples_per_item: Optional[int] = 2, total_output_samples: Optional[int] = None, operations: Optional[list] = None, interpolation: str = 'bilinear', padding_mode: str = 'zeros', resize: Optional[tuple] = None, output_extension: str = '.jpg', output_csv_path: str = 'annotations.csv', output_path: str = './augmented')¶ Bases:
object
The AugmentToDisk object allows to perform Data Image Augmentation directly to disk. That is, to save the images generated to disk to be used in future processes.
-
final_save
()¶ This method can be overwritten to make a customized saving of the items according to the interests of the user
Method that runs only once, once all the images have been processed. Useful for writing csv with image annotations. By default the annotations of all images are saved in the same file. The csv file will have one row for each generated element, identified by its id. Each column will correspond with the labels associated to each generated element. In the case of coordinate lists, their coordinates are arranged in columns separating the x and y coordinates in each element (point0_x, point0_y, point1_x, …, point_y)
-
save_item
(item: dict, index: int, output_path: str, types_2d: list, other_types: list, element: int)¶ This method can be overwritten to make a customized saving of the items according to the interests of the user
Method that implements the way to save to disk each of the generated elements. By default it saves all the generated images in the specified path. The samples are organized by name following the form:
images: <id_image>_<sample number> <extension>
other two-dimensional types: <id_image>-<data_type>_<sample number> <extension>
Annotations on the data, such as labels, or point coordinates are stored in dictionaries that will be written when all the images have been processed.
- Parameters
item – input element to be saved to disk
element – input element number to identify it
index – sample number to which the input item corresponds
output_path – path to the directory in which to save the generated data
types_2d – list of types of two dimensional data of the input item
other_types – list of types that are not two-dimensional elements
-
ida_lib.image_augmentation.data_loader module¶
-
class
ida_lib.image_augmentation.data_loader.
AugmentDataLoader
(batch_size, dataset: torch.utils.data.dataset.Dataset, shuffle=True, pipeline_operations=None, resize=None, interpolation: str = 'bilinear', padding_mode: str = 'zeros', output_format: str = 'dict', output_type: Optional[torch.dtype] = None)¶ Bases:
torch.utils.data.dataloader.DataLoader
- The DataAugmentDataLoader class implements a Pytorch DataLoader but groups it into one class:
The Dataset object that takes care of reading the data
The iterative DataLoader object that will serve as an input system for a neural network.
A pipeline that applies data image Augmentation operations over the input data.
To make use of this class, it is necessary to provide a dataset to make a personalized reading of your data.
-
class
InnerDataset
(pipeline, dataset)¶ Bases:
torch.utils.data.dataset.Dataset
inner dataset is an internal class that uses the DataAugmentDataLoader to add the pipeline to the input dataset