Input buffer size 0 is different

I wanted to retrain InceptionNet and run it on the hailo module.

The model execution code used the example module provided by hailo.

The input data used dummy data that matched the size of the input data.

However, an error of Input buffer size 0 is different occurred.

I confirmed that the input dimension and buffer initialization in the previous topic were both fine.

I ran it on Raspberry Pi 5, and the hailort version was 4.20.0 and the python version was 3.11.2.

Hey @Jinho_Park,

Welcome to the Hailo Community!

The “Input buffer size 0 is different” error occurs because you’re passing a NumPy array with zero bytes to bindings.input().set_buffer(...), while the HailoRT expects a valid frame buffer. This typically happens when your array shape contains a zero dimension - usually the batch dimension.

When you create an InferModel, it starts with a batch size of 0 (HAILO_DEFAULT_BATCH_SIZE), which means it will auto-determine the batch size during configuration. If you configure the model without explicitly setting the batch size first, you’ll end up with this issue:

infer_model = vdevice.create_infer_model('inception_net.hef')
# batch size is still 0 at this point
with infer_model.configure() as configured_infer_model:
    bindings = configured_infer_model.create_bindings()
    # infer_model.input().shape is something like (0, H, W, C)
    buffer = np.empty(infer_model.input().shape).astype(np.uint8)
    bindings.input().set_buffer(buffer)  # buffer has 0 bytes - causes the error

Solution:

Set your batch size explicitly before configuring the model. For single image inference:

infer_model = vdevice.create_infer_model('inception_net.hef')
infer_model.set_batch_size(1)  # Set batch size before configuration
with infer_model.configure() as cfg:
    bindings = cfg.create_bindings()
    shape = infer_model.input().shape  # Now (1, 224, 224, 3) for example
    buffer = np.empty(shape, dtype=np.uint8)
    bindings.input().set_buffer(buffer)  # buffer now has the correct size
    # proceed with inference...

This should resolve the buffer size mismatch error. Let me know if you have any other questions!