Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply make_divisible for ONNX models in Autoshape #10172

Merged
merged 4 commits into from
Nov 17, 2022

Commits on Nov 16, 2022

  1. Apply make_divisible for onnx models in Autoshape

    At line 697 we have this `make_divisible` function for pytorch models. 
    * Context: we want to run inference on varied input sizes instead of fixed image size.
    * When I test an image of size [720, 720] for a pytorch model (e.g., yolov5n.pt), we can see that it will be reshaped to [736, 736] by the function. This is as expected.
    * When I test the same image for the onnx model (e.g., yolov5n.onnx, exported with `--dynamic`), I got an error and it's due to the indivisible problem
    ```
    onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running Concat node. Name:'Concat_143' Status Message: concat.cc:156 PrepareForCompute Non concat axis dimensions must match: Axis 3 has mismatched dimensions of 45 and 46
    ```
    
    The simple solution is to enable the `make_divisible` function for onnx model too.
    
    Signed-off-by: janus-zheng <106574221+janus-zheng@users.noreply.github.com>
    janus-zheng committed Nov 16, 2022
    Configuration menu
    Copy the full SHA
    5e417c1 View commit details
    Browse the repository at this point in the history
  2. revise indent

    Signed-off-by: janus-zheng <106574221+janus-zheng@users.noreply.github.com>
    janus-zheng committed Nov 16, 2022
    Configuration menu
    Copy the full SHA
    867604d View commit details
    Browse the repository at this point in the history
  3. Apply make_divisible to all formats

    All formats from DetectMultiBackend should have default stride=32
    
    Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
    glenn-jocher committed Nov 16, 2022
    Configuration menu
    Copy the full SHA
    8eebb52 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6e1cdf5 View commit details
    Browse the repository at this point in the history