ida_lib.core package¶
Submodules¶
ida_lib.core.pipeline module¶
-
class
ida_lib.core.pipeline.Pipeline(pipeline_operations: list, resize: tuple = None, interpolation: str = 'bilinear', padding_mode: str = 'zeros', output_format: str = 'dict', output_type: Optional[<sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c7104f28>] = None)¶ Bases:
objectThe pipeline object represents the pipeline with data transformation operations (pictures, points). When executed, on a batch of images,it applies the necessary transformations (being different on each image based on the probabilities of each operation included).
- Considerations:
1) The images must be of the same size, or the RESIZE operation must be included so that the transformations can be applied correctly 2) To run the pipeline, it accepts any type of input metadata named in the input dict. In particular it gives special treatment
- to data named as:
- Mask: it is affected by geometric transformations and its output is discrete to values of 0-1
- Segmap: generalization of mask. Every value is discrete
- Image: affected by geometric and color transformations
- Keypoints: geometric transformations are applied to them as coordinates.
- Others: any other metadata will not be transformed (example: ‘tag’, ‘target’…)
Example:
- pip = pipeline(resize = (25, 25), pipeline_operations=(
translate_pipeline(probability=0.5, translation=(3, 0.05)), vflip_pipeline(probability=0.5), hflip_pipeline(probability=0.5), contrast_pipeline(probability=0.5, contrast_factor=1), random_brightness_pipeline(probability=0.2, brightness_range=(1.5, 1.6)), random_scale_pipeline(probability=1, scale_range=(0.5, 1.5), center_deviation=20), random_rotate_pipeline(probability=0.2, degrees_range=(-50, 50), center_deviation=20))
))
-
get_data_types() → tuple¶ Returns the tuple of data types identified on the input data
ida_lib.core.pipeline_functional module¶
-
ida_lib.core.pipeline_functional.get_compose_matrix(operations: list, data_info: Optional[dict] = None) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c7104828>¶ Returns the transformation matrix composed by the multiplication in order of the input operations (according to their probability) If data_info is not None, go through the operations by entering the necessary information about the images (image center, shape..)
Parameters: - operations – list of pipeline operations
- data_info – dict with data info to configure operations parameters
Returns: torch tensor of the transform matrix
-
ida_lib.core.pipeline_functional.get_compose_function(operations: list) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c71048d0>¶ returns the LUT table with the correspondence of each possible value according to the color operations to be implemented (according to their probability)
Parameters: operations – list of pipeline operations Returns: compose function
-
ida_lib.core.pipeline_functional.preprocess_data(data: Union[list, dict], batch_info: Union[list, dict] = None, interpolation: str = None, resize: Optional[tuple] = None) → list¶ Combines the 2d information in a tensor and the points in a homogeneous coordinate matrix that allows applying the geometric operations in a single joint operation on the data and another on the points.
- Loads the data as tensor in GPU to prepare them as input to a neural network
- Analyze the data info required for the transformations (shape, bpp…)
- Resize the 2d data and keypoints to the new shape
Parameters: - resize – if it is wanted to resize the data, indicate the new size
- data – list of elements to be transformed through the pipe
- batch_info – dict with the required data info
- interpolation – desired interpolation mode to be applied
Returns: preprocessed and resized data, and dict with batch info
-
ida_lib.core.pipeline_functional.split_operations_by_type(operations: list) → tuple¶ Split input operations into sub-lists of each transformation type the normalization operation is placed last to apply correctly the other operations
Parameters: operations – list of pipeline operations Returns: tuple of lists of the operations separated into color, geometry and independent
-
ida_lib.core.pipeline_functional.postprocess_data(batch: list, batch_info: dict, data_original: Optional[list] = None, visualize: bool = False, original_type: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c715c9e8> = <sphinx.ext.autodoc.importer._MockObject object>, output_format: str = 'dict') → list¶ Restores the data to the original form; separating the matrix into the different 2d input data and point coordinates.
Parameters: - batch – list of elements to be transformed through the pipe
- batch_info – dict with necessary information about the batch data
- data_original – original batch before transforms
- visualize – whether to run the visualization tool or not
- original_type – torch original type of the input data to do the conversion of the output data to this type
- output_format – whether to format the output element as a dict or as a tuple
Returns: processed data
-
ida_lib.core.pipeline_functional.switch_point_positions(point_matrix, input_list)¶
ida_lib.core.pipeline_geometric_ops module¶
-
class
ida_lib.core.pipeline_geometric_ops.HflipPipeline(probability: float = 1, exchange_points: tuple = None)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationHorizontally flip the input image-mask-keypoints and 2d data
-
config_parameters(data_info: dict)¶
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f78ef0>¶
-
need_data_info() → bool¶
-
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.VflipPipeline(probability: float, exchange_points: tuple = None)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationVertically flip the input image-mask-keypoints and 2d data
-
config_parameters(data_info: dict)¶
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6fc30f0>¶
-
need_data_info() → bool¶
-
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.RotatePipeline(degrees: int, center: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f78780> = None, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationRotate the input image-mask-keypoints and 2d data by the input degrees
-
config_parameters(data_info: dict)¶
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f787b8>¶
-
need_data_info() → bool¶
-
static
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.ShearPipeline(shear: tuple, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationShear the input image-mask-keypoints and 2d data by the input shear factor
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f78a90>¶
-
static
need_data_info() → bool¶
-
static
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.ScalePipeline(scale_factor: Union[float, tuple], probability: float = 1, center: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f6eef0> = None)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationScale the input image-mask-keypoints and 2d data by the input scaling value
-
config_parameters(data_info: dict)¶
-
get_op_matrix()¶
-
need_data_info()¶
-
static
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.TranslatePipeline(translation: tuple, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationTranslate the input image-mask-keypoints and 2d data by the input translation
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f54390>¶
-
static
need_data_info() → bool¶
-
static
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.RandomScalePipeline(probability: float, scale_range: tuple, keep_aspect: bool = True, center_deviation: int = None, center: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f78550> = None)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationScale the input image-mask-keypoints and 2d data by a random scaling value calculated within the input range
-
config_parameters(data_info: dict)¶
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f78588>¶
-
need_data_info() → bool¶
-
static
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.RandomRotatePipeline(degrees_range: tuple, probability: float = 1, center_deviation: int = None, center: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f789b0> = None)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationRotate the input image-mask-keypoints and 2d data by a random scaling value calculated within the input range
-
config_parameters(data_info: dict)¶
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f789e8>¶
-
need_data_info() → bool¶
-
static
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.RandomShearPipeline(probability: float, shear_range: tuple)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationShear the input image-mask-keypoints and 2d data by a random shear value calculated within the input range
-
get_op_matrix() → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f78cc0>¶
-
static
need_data_info() → bool¶
-
static
switch_points()¶
-
-
class
ida_lib.core.pipeline_geometric_ops.RandomTranslatePipeline(probability: float, translation_range: tuple, same_translation_on_axis: bool = False)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationTranslate the input image-mask-keypoints and 2d data by a random translation value calculated within the input range
-
get_op_matrix()¶
-
static
need_data_info() → bool¶
-
static
switch_points()¶
-
ida_lib.core.pipeline_local_ops module¶
-
class
ida_lib.core.pipeline_local_ops.BlurPipeline(probability: float = 1, blur_size: tuple = (5, 5))¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationBlur input image ( non-weighted blur)
-
apply_to_image_if_probability(img: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6ec7da0>) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6ec7d68>¶
-
get_op_matrix()¶
-
-
class
ida_lib.core.pipeline_local_ops.GaussianBlurPipeline(probability: float = 1, blur_size: tuple = (5, 5))¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationBlur input image by a Gaussian function
-
apply_to_image_if_probability(img: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6ec77f0>) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6ec7828>¶
-
get_op_matrix()¶
-
-
class
ida_lib.core.pipeline_local_ops.GaussianNoisePipeline(probability: float = 1, var: float = 0.5)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationAdd gaussian noise to the input image (gaussian noise is a statistical noise having a probability density function (PDF) equal to that of the normal distribution)
-
apply_to_image_if_probability(img: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f12668>) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f126a0>¶
-
get_op_matrix()¶
-
-
class
ida_lib.core.pipeline_local_ops.PoissonNoisePipeline(probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationAdd poison noise to the input image ( It is applied by adding Poisson-distributed noise)
-
apply_to_image_if_probability(img: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6ec75f8>) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6ec7630>¶
-
get_op_matrix()¶
-
-
class
ida_lib.core.pipeline_local_ops.SaltAndPepperNoisePipeline(probability=1, amount: Optional[float] = 0.01, s_vs_p: Optional[float] = 0.5)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationAdd salt and pepper noise to the input image (salt-and-pepper noise is a statistical noise compose of white (salt) and black (pepper) pixels)
-
apply_to_image_if_probability(img: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f9e5c0>) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f9e198>¶
-
get_op_matrix()¶
-
-
class
ida_lib.core.pipeline_local_ops.SpekleNoisePipeline(probability: float = 1, mean: Optional[float] = 0, var: Optional[float] = 0.01)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationAdd spekle noise to the input image (Speckle is a granular interference that inherently exists in and degrades the quality of the active radar, synthetic aperture radar (SAR), medical ultrasound and optical coherence tomography images. It is applied by adding the image multiplied by the noise matrix -> img + img * uniform_noise)
-
apply_to_image_if_probability(img: <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f9e278>) → <sphinx.ext.autodoc.importer._MockObject object at 0x7fe3c6f9e358>¶
-
get_op_matrix()¶
-
ida_lib.core.pipeline_operations module¶
ida_lib.core.pipeline_pixel_ops module¶
-
class
ida_lib.core.pipeline_pixel_ops.ContrastPipeline(contrast_factor: float, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationChange the contrast of the input image.
-
get_op_matrix()¶
-
transform_function(x: int) → float¶
-
-
class
ida_lib.core.pipeline_pixel_ops.RandomContrastPipeline(contrast_range: tuple, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationChange the contrast of the input image with a random contrast factor calculated within the input range
-
get_op_matrix()¶
-
transform_function(x)¶
-
-
class
ida_lib.core.pipeline_pixel_ops.BrightnessPipeline(brightness_factor: float, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationChange brightness of the input image
-
get_op_matrix()¶
-
get_op_type()¶
-
transform_function(x: int) → float¶
-
-
class
ida_lib.core.pipeline_pixel_ops.RandomBrightnessPipeline(probability: float, brightness_range: tuple)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationChange brightness of the input image to random amount calculated within the input range
-
get_op_matrix()¶
-
get_op_type()¶
-
transform_function(x: int) → float¶
-
-
class
ida_lib.core.pipeline_pixel_ops.GammaPipeline(gamma_factor: float, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationChange the luminance of the input image
-
get_op_matrix()¶
-
transform_function(x: int) → float¶
-
-
class
ida_lib.core.pipeline_pixel_ops.RandomGammaPipeline(gamma_range: tuple, probability: float = 1)¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationChange the luminance of the input image by a random gamma factor calculated within the input range
-
get_op_matrix()¶
-
transform_function(x: int) → float¶
-
-
class
ida_lib.core.pipeline_pixel_ops.NormalizePipeline(probability: float = 1, old_range: tuple = (0, 255), new_range: tuple = (0, 1))¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationChange the pixels value to a normalize range
-
get_op_matrix()¶
-
static
transform_function(x: int) → float¶
-
-
class
ida_lib.core.pipeline_pixel_ops.DenormalizePipeline(probability: float = 1, old_range: tuple = (0, 1), new_range: tuple = (0, 255))¶ Bases:
ida_lib.core.pipeline_operations.PipelineOperationDenormalize pixel value
-
get_op_matrix()¶
-
transform_function(x: int) → float¶
-