Are dynamic input shapes a problem for Yolov8 models loaded with readNetFromONNX?

dynamic input (or layer) shape does not work with opencv. Dynamic means at inference time.
But with onnx model if input is dynamic you can set input shape :

  1. simplify model
    onnxsim a.onnx a.sim.onnx
  2. use netron to know input and name shape

  1. fixed input shape using
python -m onnxruntime.tools.make_dynamic_shape_fixed --dim_param batch --dim_value 1 a.sim.onnx a1.onnx
python -m onnxruntime.tools.make_dynamic_shape_fixed --dim_param width --dim_value 640 a1.onnx a2.onnx
python -m onnxruntime.tools.make_dynamic_shape_fixed --dim_param height --dim_value 480 a2.onnx a3.onnx

Sometimes data input layer are dynamic then post an issue

1 Like