简体   繁体   中英

How to convert a style transfer tensorflow model to mlmodel with flexible input shape?

I have read the Coreml guide which shows how to convert a pb model to mlmodel by using coremltools. However, I get the error below when trying to follow the guide. Which means the input shape must be specific.

ValueError: "ResizeBilinear" op: the second input, which is the output size, must be known statically

So, have anyone know how to convert the flexible input shape mlmodel?

Here is my code:

import coremltools as ct

def mlmodel_image(pb):
    input_shape = ct.Shape(shape=(1, ct.RangeDim(1, 720), ct.RangeDim(1, 1280), 3))
    model_input = ct.ImageType(shape=input_shape)
    mlmodel = ct.convert(pb, inputs=[model_input], source='TensorFlow')
    mlmodel.save(pb.replace(".pb", "_img.mlmodel"))
    print('------save to ', pb.replace(".pb", "_img.mlmodel"))

please try my sample: https://github.com/dhrebeniuk/RealTimeFastStyleTransfer

And look my article with attached Google Colab Notebook in PyTorch.

There is instructions how run Style Transfer on iOS with maximum performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM