opencv_zoo icon indicating copy to clipboard operation
opencv_zoo copied to clipboard

torch.nn.functional.interpolate is unsupport!

Open Wwupup opened this issue 2 years ago • 1 comments

I meet error when run: python demo.py -m model.onnx -i imgfile.jpg 83f9eacadf6f2ef4705beb3d534d15f It seems that the latest version don`t support upsample operation. The onnx model in Netron: 9cff13bbe00711cefe483c97a7237e8

Wwupup avatar Aug 08 '22 12:08 Wwupup

The problems are:

  1. OpenCV DNN does not support ONNX model with dynamic input shape. However, we have a clear plan to support this in OpenCV 5.x.
  2. For fixed input shape, the resize operators have fixed target size as input. So for OpenCV DNN, when it takes a input of different size, the ouputs of resize operators will have a wrong shape.

Current solution is:

  1. Export this model with resize operators with scale 2 as input instead of fixed size.
  2. Resize the input so that its width and height can be divisible by 64.
  3. Get the lastest OpenCV: pip install opencv-python-rolling.

Code needs to be changed in libfacedetection.train:

-                size=[feats[i].size(2), feats[i].size(3)], 
+                scale = 2,

We will have a discussion on whether we should replace the one currently in the zoo with this model today.

fengyuentau avatar Aug 25 '22 03:08 fengyuentau