src/models/utils/building_blocks.py
def preprocessing_block(x,
                        centercrop=False,
                        crop_x=256,
                        crop_y=256,
                        rescaling=True,
                        rescale_value=(1.0/255)
                        ):

    '''
    Returns the output tensor of a data preprocessing block given an input tensor x. The preprocessing is done inside the model.

    Parameters:
        x (tensor): the entry tensor.
        centercrop (bool): whether to apply CenterCrop or not.
        crop_x (int): center crop x size.
        crop_y (int): center crop y size.
        rescaling (bool): whether to apply rescaling or not.
        rescale_value (float): value to which rescale pixel values -> pixel_values * rescale_value

    Returns:
        x (tensor): Tensor outputs of original tensor x passing through the defined preprocessing block.
    '''

    if centercrop:
        x = layers.experimental.preprocessing.CenterCrop(crop_x,crop_y)(x)

    if rescaling:
        x = layers.experimental.preprocessing.Rescaling(rescale_value)(x)
    
    return x

    Returns the output tensor of a data preprocessing block given an input tensor x. The preprocessing is done inside the model.

    Parameters:
        x (tensor): the entry tensor.
        centercrop (bool): whether to apply CenterCrop or not.
        crop_x (int): center crop x size.
        crop_y (int): center crop y size.
        rescaling (bool): whether to apply rescaling or not.
        rescale_value (float): value to which rescale pixel values -> pixel_values * rescale_value

    Returns:
        x (tensor): Tensor outputs of original tensor x passing through the defined preprocessing block.
    
Returns the output tensor of a data preprocessing block given an input tensor x. The preprocessing is done inside the model.
Returns the output tensor of a data preprocessing block given an input tensor x . The preprocessing is done inside the model .
def preprocessing_block(x,
                        centercrop=False,
                        crop_x=256,
                        crop_y=256,
                        rescaling=True,
                        rescale_value=(1.0/255)
                        ):
    if centercrop:
        x = layers.experimental.preprocessing.CenterCrop(crop_x,crop_y)(x)
    if rescaling:
        x = layers.experimental.preprocessing.Rescaling(rescale_value)(x)
    return x
def preprocessing_block ( x , centercrop = False , crop_x = 256 , crop_y = 256 , rescaling = True , rescale_value = ( 1.0 / 255 ) ) : if centercrop : x = layers . experimental . preprocessing . CenterCrop ( crop_x , crop_y ) ( x ) if rescaling : x = layers . experimental . preprocessing . Rescaling ( rescale_value ) ( x ) return x
Returns the output tensor of a data preprocessing block given an input tensor x.
Returns the output tensor of a data preprocessing block given an input tensor x .
'''
    Returns the output tensor of a data preprocessing block given an input tensor x. The preprocessing is done inside the model.

    Parameters:
        x (tensor): the entry tensor.
        centercrop (bool): whether to apply CenterCrop or not.
        crop_x (int): center crop x size.
        crop_y (int): center crop y size.
        rescaling (bool): whether to apply rescaling or not.
        rescale_value (float): value to which rescale pixel values -> pixel_values * rescale_value

    Returns:
        x (tensor): Tensor outputs of original tensor x passing through the defined preprocessing block.
    '''
x (tensor): Tensor outputs of original tensor x passing through the defined preprocessing block.
x ( tensor ) : Tensor outputs of original tensor x passing through the defined preprocessing block .
x
the entry tensor.
the entry tensor .
centercrop
whether to apply CenterCrop or not.
whether to apply CenterCrop or not .
crop_x
center crop x size.
center crop x size .
crop_y
center crop y size.
center crop y size .
rescaling
whether to apply rescaling or not.
whether to apply rescaling or not .
rescale_value
value to which rescale pixel values -> pixel_values * rescale_value
value to which rescale pixel values - > pixel_values * rescale_value