Set flexible input shape for CoreML Model

MLBoy
1 min readFeb 1, 2022

--

It is a method to convert to a CoreML model that can support various input shapes.

We want to use input of various sizes instead of fixed

With the default conversion, the CoreML model fixes the input size.
However, in real-world use cases, you may want to use inputs of different sizes.

How to use flexible input

CoreMLTools allows flexible input settings.

How to set at the time of conversion

The model can now accept a range of 512 to 1024 vertically and horizontally in the input image.
ct.RangeDim () will accept an unlimited number of input shape.

It is faster than range specification by pre-allocating memory by setting some default values ​​instead of range specification.

Now you can specify the input shape with three choices.

How to set after conversion

🐣

I’m a freelance engineer.
Work consultation
Please feel free to contact us with a brief development description.
rockyshikoku@gmail.com

I am making an app that uses Core ML and ARKit.
We send machine learning / AR related information.

GitHub

Twitter
Medium

--

--

MLBoy
MLBoy

No responses yet