@nadav, @Omer - this was the closest post I could find to creating custom nms configs, hopefully you can help. I’m attempting to compile yolov5-p2 to .hef
My end nodes are like so:
parsing code
runner = ClientRunner(hw_arch=chosen_hw_arch)
hn, npz = runner.translate_onnx_model(
onnx_path,
onnx_model_name,
start_node_names=["/model.0/conv/Conv"],
end_node_names=["/model.31/m.3/Conv",
"/model.31/m.2/Conv",
"/model.31/m.1/Conv",
"/model.31/m.0/Conv"],
net_input_shapes={"/model.0/conv/Conv": [1, 3, 640, 640]},
)
and I inspected the parsed model layers to check the renmaed nodes:
har output layers
('yolov5np2_visdrone/output_layer1',
OrderedDict([('type', 'output_layer'),
('input', ['yolov5np2_visdrone/conv89']),
('output', []),
('input_shapes', [[-1, 160, 160, 18]]),
('output_shapes', [[-1, 160, 160, 18]]),
('original_names', ['out']),
('compilation_params', {}),
('quantization_params', {}),
('transposed', False),
('engine', 'nn_core'),
('io_type', 'standard')])),
('yolov5np2_visdrone/output_layer2',
OrderedDict([('type', 'output_layer'),
('input', ['yolov5np2_visdrone/conv99']),
('output', []),
('input_shapes', [[-1, 80, 80, 18]]),
('output_shapes', [[-1, 80, 80, 18]]),
('original_names', ['out']),
('compilation_params', {}),
('quantization_params', {}),
('transposed', False),
('engine', 'nn_core'),
('io_type', 'standard')])),
('yolov5np2_visdrone/output_layer3',
OrderedDict([('type', 'output_layer'),
('input', ['yolov5np2_visdrone/conv111']),
('output', []),
('input_shapes', [[-1, 40, 40, 18]]),
('output_shapes', [[-1, 40, 40, 18]]),
('original_names', ['out']),
('compilation_params', {}),
('quantization_params', {}),
('transposed', False),
('engine', 'nn_core'),
('io_type', 'standard')])),
('yolov5np2_visdrone/output_layer4',
OrderedDict([('type', 'output_layer'),
('input', ['yolov5np2_visdrone/conv121']),
('output', []),
('input_shapes', [[-1, 20, 20, 18]]),
('output_shapes', [[-1, 20, 20, 18]]),
('original_names', ['out']),
('compilation_params', {}),
('quantization_params', {}),
('transposed', False),
('engine', 'nn_core'),
('io_type', 'standard')]))])
So to create the nms config, I used one of the yolov5 configs but added an extra bbox_decoder and updated the anchors:
custom model nms config
{
"nms_scores_th": 0.001,
"nms_iou_th": 0.6,
"image_dims": [
640,
640
],
"max_proposals_per_class": 100,
"background_removal": false,
"classes": 1,
"bbox_decoders": [
{
"name": "bbox_decoder89",
"w": [
2.01172,
2.68945,
4.41016
],
"h": [
3.97266,
5.95312,
5.50000
],
"stride": 8,
"encoded_layer": "conv89"
},
{
"name": "bbox_decoder99",
"w": [
3.53125,
5.31641,
5.08594
],
"h": [
8.80469,
8.64062,
12.39062
],
"stride": 16,
"encoded_layer": "conv99"
},
{
"name": "bbox_decoder111",
"w": [
8.03906,
6.73438,
9.27344
],
"h": [
10.12500,
15.82812,
17.54688
],
"stride": 32,
"encoded_layer": "conv111"
},
{
"name": "bbox_decoder121",
"w": [
11.79688,
15.61719,
34.09375
],
"h": [
21.31250,
29.06250,
36.06250
],
"stride": 64,
"encoded_layer": "conv121"
}
]
}
This will optimize without error but the model is unable to detect objects, just plots rectangles around nothing, even if I only use full precision
alls = """
normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])
change_output_activation(sigmoid)
model_optimization_config(calibration, batch_size=8, calibset_size=64)
post_quantization_optimization(finetune, policy=enabled, learning_rate=0.00001, epochs=4, batch_size=8, dataset_size=1024)
nms_postprocess("/local/shared_with_docker/visdrone/postprocess_config/yolov5np2v6_nms_config_custom.json", yolov5, engine=cpu)
performance_param(compiler_optimization_level=max)
allocator_param(width_splitter_defuse=disabled)
# """
runner.load_model_script(alls)
runner.optimize_full_precision()
Any suggestions as to where I’m going wrong here?