STM32N6 NPU Deployment — Politecnico di Milano  1.0
Documentation for Neural Network Deployment on STM32N6 NPU - Politecnico di Milano 2024-2025
preprocess Namespace Reference

Functions

Tuple preprocess (DictConfig cfg=None)
 
def apply_rescaling (tf.data.Dataset dataset=None, float scale=None, float offset=None)
 
tf.Tensor preprocess_input (np.ndarray image, dict input_details)
 

Function Documentation

◆ apply_rescaling()

def preprocess.apply_rescaling ( tf.data.Dataset   dataset = None,
float   scale = None,
float   offset = None 
)
Applies rescaling to a dataset using a tf.keras.Sequential model.

Args:
    dataset (tf.data.Dataset): The dataset to be rescaled.
    scale (float): The scaling factor.
    offset (float): The offset factor.

Returns:
    The rescaled dataset.

Definition at line 87 of file preprocess.py.

Referenced by evaluate.evaluate(), and quantize.quantize().

Here is the caller graph for this function:

◆ preprocess()

Tuple preprocess.preprocess ( DictConfig   cfg = None)
Preprocesses the data based on the provided configuration.

Args:
    cfg (DictConfig): Configuration object containing the settings.

Returns:
    Tuple: A tuple containing the following:
        - data_augmentation (object): Data augmentation object.
        - augment (bool): Flag indicating whether data augmentation is enabled.
        - pre_process (object): Preprocessing object.
        - train_ds (object): Training dataset.
        - valid_ds (object): Validation dataset.

Definition at line 36 of file preprocess.py.

References data_loader.load_dataset().

Here is the call graph for this function:

◆ preprocess_input()

tf.Tensor preprocess.preprocess_input ( np.ndarray  image,
dict  input_details 
)
Preprocesses an input image according to input details.

Args:
    image: Input image as a NumPy array.
    input_details: Dictionary containing input details, including quantization and dtype.

Returns:
    Preprocessed image as a TensorFlow tensor.

Definition at line 111 of file preprocess.py.