This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_normalization_to_onnx(model_path: str, first_node_name: str, mean: list, std: list): | |
''' | |
Edit the exported onnx model => add preprocess layer: sub mean and div std | |
''' | |
model = onnx.load(model_path) | |
onnx.save(model, model_path.replace('inference', 'raw_inference')) | |
# Assuming the input of your model is a single tensor of shape (batch_size, num_channels, height, width) | |
input_tensor = model.graph.input[0] |