Resize Layer compiled into the HEF file

How is the model script function resize supposed to work, should you be able to make inference on any image resolution when resize is done on the input layer?

have compiled both a yolov5 and yolov8 with resize to 640x480 but when i do inference with the emulator and model_compiled.har I get the error:

ValueError: Input 0 of layer “model/input_layer1” is incompatible with the layer: expected shape=(None, 480, 640, 3), found shape=(None, 486, 648, 3)

Have also tried the model.hef on HW but get similar errors:

[HailoRT] [error] CHECK failed - write size 944784 must be 921600

Here is the model script for yolov5

normalization1 = normalization([0.0, 0.0, 0.0], [255.0, 255.0, 255.0])
resize_input1 = resize(resize_shapes=[480,640])
nms_postprocess(meta_arch=yolov5, nms_scores_th=0.2, nms_iou_th=0.6, engine=nn_core)
model_optimization_config(calibration, batch_size=16, calibset_size=512)

All the layers that are being compiled to the Hailo device are statically alocated, which also dictates static input shape.
For the reshape layer in your case, it means that you’ve added a static resize [640x480] → [640x640] to be ran on the device. This means that now the new input size is [640x480].
Unfortunately we do not support dynamic resize, the suggested way to cope with it depends on the system at hand. Once option is to resize on the host. Another option is to crop/resize the image at the ISP of the camera.

1 Like