Fail to run analyze noise on custom YOLOv11

code
with open(“optimize_model.py”, “w”) as f:

f.write(“”"

import os

from hailo_sdk_client import ClientRunner

Define your model’s HAR file name

model_name = “yolov11s”

hailo_model_har_name = f"/content/drive/MyDrive/orangePI/Hailo/yolov11/{model_name}_hailo_model.har"

Ensure the HAR file exists

assert os.path.isfile(hailo_model_har_name), “Please provide a valid path for the HAR file”

Initialize the ClientRunner with the HAR file

runner = ClientRunner(har=hailo_model_har_name)

Define the model script to add a normalization layer

Normalization for [0, 1] range

alls = """

normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])

change_output_activation(conv54, sigmoid)

change_output_activation(conv65, sigmoid)

change_output_activation(conv80, sigmoid)

nms_postprocess(“/content/drive/MyDrive/Hailo/yolov11/yolov11_nms_layer_config.json”, meta_arch=yolov8, engine=cpu)

"""

Load the model script into the ClientRunner

runner.load_model_script(alls)

Define a calibration dataset

calib_dataset = “/content/drive/MyDrive/Hailo/yolov11/processed_calibration_data.npy”

Perform optimization with the calibration dataset

runner.optimize(calib_dataset)

runner.analyze_noise(calib_dataset, batch_size=2, data_count=16)

Save the optimized model to a new Quantized HAR file

quantized_model_har_path = f"/content/drive/MyDrive/orangePI/Hailo/yolov11/{model_name}_quantized_model.har"

runner.save_har(quantized_model_har_path)

print(f"Quantized HAR file saved to: {quantized_model_har_path}")

“”")

error
ValueError: Exception encountered when calling layer ‘lat_model’ (type LATModel).

in user code:

    File "/content/my_env/lib/python3.10/site-packages/hailo_model_optimization/algorithms/lat_utils/lat_model.py", line 392, in call  *
        metric.update_state(native, numeric, partial_numeric=partial_numeric)
    File "/content/my_env/lib/python3.10/site-packages/hailo_model_optimization/algorithms/lat_utils/lat_model.py", line 22, in update_state  *
        self.noise_energy.assign_add(tf.reduce_mean((native - numeric) ** 2))

    ValueError: Dimensions must be equal, but are 128 and 132 for '{{node lat_model/sub_295}} = Sub[T=DT_FLOAT](lat_model/conv_feature_splitter6_2/act_op/Identity, lat_model/conv_feature_splitter6_2/output_op/mul)' with input shapes: [2,1,400,128], [2,1,400,132].


Call arguments received by layer 'lat_model' (type LATModel):
  • inputs=tf.Tensor(shape=(2, 640, 640, 3), dtype=float32)

Full Quant Analysis: 12%|█▎ | 1/8 [00:55<06:31, 55.86s/iterations]