mmdeploy icon indicating copy to clipboard operation
mmdeploy copied to clipboard

Confusing Results on ONNX model

Open sarmientoj24 opened this issue 3 years ago • 1 comments

I was able to successfully convert the model from mmdet to ONNX.

python mmdeploy/tools/deploy.py mmdeploy/configs/mmdet/detection/detection_onnxruntime_static.py config.py model.pth sample.jpg --show --log-level INFO --dump-info

Using onnx_static

This is the end of the ONNX model as seen via Netron image

I created a session and ran with this command

output = session.run(
    [session.get_outputs()[0].name], {session.get_inputs()[0].name: image_data}
)[0]

However, the output is shaped (1, 9 , 5) and I have 32 classes.

array([[[9.81685867e+01, 3.41811523e+02, 2.91662201e+02, 5.47197327e+02,
         9.97480333e-01],
        [2.85189941e+02, 3.26651062e+02, 4.63471863e+02, 5.43583923e+02,
         9.95274007e-01],
        [6.36424255e+00, 3.46747955e+02, 1.15773026e+02, 5.46975647e+02,
         9.94173467e-01],
        [1.17616814e+02, 9.96136322e+01, 3.02284515e+02, 2.98620605e+02,
         9.93754327e-01],
        [2.90171295e+02, 9.86118469e+01, 4.62554901e+02, 2.93593506e+02,
         9.88694847e-01],
        [6.60939026e+00, 9.31959305e+01, 1.33459366e+02, 3.00427856e+02,
         9.87612784e-01],
        [6.67033768e+00, 3.48291016e+02, 1.16874954e+02, 5.43394348e+02,
         9.15506855e-02],
        [2.94228333e+02, 1.02716454e+02, 4.62453369e+02, 2.97128387e+02,
         5.30423671e-02],
        [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
         0.00000000e+00]]], dtype=float32)

How do I parse this? It doesnt make any sense.

Moreover, I am using Faster-RCNN. Do I still have to normalize it prior to input?

sarmientoj24 avatar Jun 23 '22 18:06 sarmientoj24

Hi, @sarmientoj24 The output shape (1, 9, 5) means you have 9 detected bboxes, and each of them has 5 values, which means the related coordinate and side length, and confidence, a.k.a (x, y, w, h, c). The transformation of these value to the real coordinate for Faster-RCNN, please refer to implementation of delta_xywh_bbox_coder

hanrui1sensetime avatar Jun 29 '22 06:06 hanrui1sensetime