keras2ncnn icon indicating copy to clipboard operation
keras2ncnn copied to clipboard

Added support for Resizing op

Open Pascal0902 opened this issue 4 years ago • 2 comments

Hello everyone,

this PR aims to enable Resizing op support. The implementation translates tensorflow resizing ops into NCNN Interpolation Ops.

As ncnn expects a scale factor for these ops, the input shape of the layer must be known. I am currently using keras to load the model and determine the input_shape. There would be other ways that don't require keras, if you want to use one of those instead please feel free to do so.

To my knowledge NCNN currently only supports the "bilinear" and "nearest" interpolation methods, so using any other interpolation method will raise an Error while converting the model.

The implementation worked flawlessly in my tests. Please feel free to perform your own tests, since a second pair of eyes is always appreciated.

Pascal0902 avatar Oct 15 '21 14:10 Pascal0902

Cool. Thanks for the PR!

Light and not requiring keras or tf is something that I am trying to achieve. Maybe you can take a look at this code I wrote for another project for static shape inference, hmmm let me think for a momet.

https://github.com/microsoft/nn-Meter/blob/a478371d309a53fdd19f4d1c497017c5aabb902a/nn_meter/ir_converters/frozenpb_converter/shape_inference.py

MarsTechHAN avatar Oct 17 '21 06:10 MarsTechHAN

Thanks for the reply!

I looked at the code you send, should work for this case as well. Needs some changes to work in this project of course.

I will test that code and update the PR as soon as I find the time.

Pascal0902 avatar Oct 18 '21 07:10 Pascal0902