Parsing Error for P2 head in YOLOv8

Hey,
I am trying to compile custom trained YOLOv8m with P2 head model to hef file. But even though i have made changes in .yaml file and given nodes name according to my model :

parser:
nodes:

  • null
    • /model.28/Concat_4
      end-node-names:
  • /model.28/cv2.0/cv2.0.2/Conv
  • /model.28/cv3.0/cv3.0.2/Conv
  • /model.28/cv2.1/cv2.1.2/Conv
  • /model.28/cv3.1/cv3.1.2/Conv
  • /model.28/cv2.2/cv2.2.2/Conv
  • /model.28/cv3.2/cv3.2.2/Conv
  • /model.28/cv2.3/cv2.3.2/Conv
  • /model.28/cv3.3/cv3.3.2/Conv

when I am doing :
hailomz compile --yaml yolov8m.yaml --ckpt yolo8m.onnx --hw-arch hailo8 --calib-path ThermalImages --classes 13

or trying to parse the
hailomz parse --yaml yolov8m.yaml --ckpt yolo8m.onnx --hw-arch hailo8

the generated .har file should have output layer 1, output layer 2 and so on. But It is not able to generate that instead it is being concatenated.

Due to which i am facing error in further compilation.

Hey @Suraj_Upadhyay,

You’re getting one big concatenated output instead of separate detection layers because the parser is diving too deep into your YOLOv8 model - it’s going past your intended stopping point and picking up Ultralytics’ built-in postprocessing layers (things like Concat, Sigmoid, DFL, etc.).

Could you share your alls and yaml files for this compilation?
The easiest way for me to help is if you can provide the alls and yaml files, and then I can take a look at what’s going on!

.yaml :

base:

/local/shared_with_docker/8m/yolo.yaml

postprocessing:
device_pre_post_layers:
nms: true
hpp: true

network:
network_name: yolov8m

paths:
network_path:

/local/shared_with_docker/8m/yolo8m.onnx
alls_script: /local/shared_with_docker/8m/yolov8m.alls
url: https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ObjectDetection/Detection-COCO/yolo/yolov8m/2023-02-02/yolov8m.zip

parser:
nodes:

null

/model.28/Concat_4
end-node-names:

/model.28/cv2.0/cv2.0.2/Conv

/model.28/cv3.0/cv3.0.2/Conv

/model.28/cv2.1/cv2.1.2/Conv

/model.28/cv3.1/cv3.1.2/Conv

/model.28/cv2.2/cv2.2.2/Conv

/model.28/cv3.2/cv3.2.2/Conv

/model.28/cv2.3/cv2.3.2/Conv

/model.28/cv3.3/cv3.3.2/Conv

info:
task: object detection
input_shape: 512x640x3
output_shape: 17x27200
operations: 165.3G
parameters: 43.7M
framework: pytorch
training_data: coco train2017
validation_data: coco val2017
eval_metric: mAP
full_precision_result: 52.61
source: 

license_url: 

license_name: GPL-3.0

quantization:
calib_path: ThermalImages/
calib_num_images: 1024
calib_batch_size: 8

postprocess:
nms_config_path: yolov8m_nms_config.json

.alls :

yolov8m.alls — fixed to use /model.28/Concat_4 as the end node

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

model_optimization_config(calibration, batch_size=2)

model_optimization_flavor(optimization_level=0, compression_level=0)

post_quantization_optimization(adaround, policy=enabled, epochs=320, batch_size=2)

change_output_activation(conv63, sigmoid)
change_output_activation(conv76, sigmoid)
change_output_activation(conv89, sigmoid)
change_output_activation(conv102, sigmoid)

nms_postprocess(“yolov8m_nms_config.json”, meta_arch=yolov8, engine=cpu)

@omria I got the solution for above. But i wanted to know is there a way to reduce context of heavy models like yolov8m or 8l which has 3 and 4 contexts.

i tried reducing parameters and number of layers but still same result.

Hey @Suraj_Upadhyay ,

To reduce the number of contexts for large models on Hailo devices, the most effective approaches are:

  • Increasing the compression level
  • Enabling performance mode
  • Reducing input resolution

Keep in mind that for very large models, hardware limitations may prevent them from fitting into a single context, even with these optimizations applied.