coremltools

coremltools: how to properly use NeuralNetworkMultiArrayShapeRange?

浪尽此生 提交于 2021-01-29 16:28:12
问题 I have a PyTorch network and I want to deploy it to iOS devices. In short, I fail to add flexibility to the input tensor shape in CoreML. The network is a convnet that takes an RGB image (stored as a tensor) as an input and returns an RGB image of the same size. Using PyTorch, I can input images of any size I want, for instance a tensor of size (1, 3, 300, 300) for a 300x300 image. To convert the PyTorch model to a CoreML model, I first convert it to an ONNX model using torch.onnx.export .

TypeError: 'InputLayer' object is not iterable with CoreMLTools

ぐ巨炮叔叔 提交于 2021-01-07 02:32:34
问题 I'm trying to convert a VGG model to coremltools. When I run the following code to convert the model: with CustomObjectScope({'relu6': keras.layers.ReLU,'DepthwiseConv2D': keras.layers.DepthwiseConv2D}): from keras.models import load_model import coremltools model_directory = 'KerasModels/VGG-7-3-20_13categories.h5' keras_model = load_model(model_directory) input_layer = InputLayer(input_shape=(224, 224, 3), name="input_1") # Save and convert : keras_model.layers[0] = input_layer keras_model

TypeError: 'InputLayer' object is not iterable with CoreMLTools

 ̄綄美尐妖づ 提交于 2021-01-07 02:31:30
问题 I'm trying to convert a VGG model to coremltools. When I run the following code to convert the model: with CustomObjectScope({'relu6': keras.layers.ReLU,'DepthwiseConv2D': keras.layers.DepthwiseConv2D}): from keras.models import load_model import coremltools model_directory = 'KerasModels/VGG-7-3-20_13categories.h5' keras_model = load_model(model_directory) input_layer = InputLayer(input_shape=(224, 224, 3), name="input_1") # Save and convert : keras_model.layers[0] = input_layer keras_model

Coremltools error while converting: “'str' object has no attribute 'decode'” [duplicate]

五迷三道 提交于 2021-01-05 06:04:16
问题 This question already has an answer here : Save keras model as .h5 (1 answer) Closed last month . I am trying to use coremltools to convert a keras model to mlmodel. I am getting the following code: import coremltools import keras output_labels = list(range(1, 43)) your_model = coremltools.converters.keras.convert('my_model.h5', input_names=['image'], output_names=['output'], class_labels=output_labels, image_input_names='image') #your_model.author = 'your name' #your_model.short_description

Coremltools error while converting: “'str' object has no attribute 'decode'” [duplicate]

时间秒杀一切 提交于 2021-01-05 06:03:45
问题 This question already has an answer here : Save keras model as .h5 (1 answer) Closed last month . I am trying to use coremltools to convert a keras model to mlmodel. I am getting the following code: import coremltools import keras output_labels = list(range(1, 43)) your_model = coremltools.converters.keras.convert('my_model.h5', input_names=['image'], output_names=['output'], class_labels=output_labels, image_input_names='image') #your_model.author = 'your name' #your_model.short_description

Compatibility between keras and tf.keras models

怎甘沉沦 提交于 2020-12-29 18:17:54
问题 I am interested in training a model in tf.keras and then loading it with keras. I know this is not highly-advised, but I am interested in using tf.keras to train the model because tf.keras is easier to build input pipelines I want to take advantage of the tf.dataset API and I am interested in loading it with keras because I want to use coreml to deploy the model to ios. I want to use coremltools to convert my model to ios, and coreml tools only works with keras, not tf.keras. I have run into

Compatibility between keras and tf.keras models

北战南征 提交于 2020-12-29 18:17:18
问题 I am interested in training a model in tf.keras and then loading it with keras. I know this is not highly-advised, but I am interested in using tf.keras to train the model because tf.keras is easier to build input pipelines I want to take advantage of the tf.dataset API and I am interested in loading it with keras because I want to use coreml to deploy the model to ios. I want to use coremltools to convert my model to ios, and coreml tools only works with keras, not tf.keras. I have run into

Compatibility between keras and tf.keras models

扶醉桌前 提交于 2020-12-29 18:16:37
问题 I am interested in training a model in tf.keras and then loading it with keras. I know this is not highly-advised, but I am interested in using tf.keras to train the model because tf.keras is easier to build input pipelines I want to take advantage of the tf.dataset API and I am interested in loading it with keras because I want to use coreml to deploy the model to ios. I want to use coremltools to convert my model to ios, and coreml tools only works with keras, not tf.keras. I have run into

MLModel works with MultiArray output but cannot successfully change the output to an image

旧城冷巷雨未停 提交于 2020-12-13 11:16:52
问题 I have converted a Keras model to a MLModel using coremltools 4.0 with limited success. It works but only if I use an MLMultiArray for the output and covert to an image. Converting to an image takes magnitudes longer than inferencing; making it unusable. If I try to change the MLModel spec to use images for output I get this error running prediction: Failed to convert output Identity to image: NSUnderlyingError=0x2809bad00 {Error Domain=com.apple.CoreML Code=0 "Invalid array shape ( 2048,

MLModel works with MultiArray output but cannot successfully change the output to an image

▼魔方 西西 提交于 2020-12-13 11:16:24
问题 I have converted a Keras model to a MLModel using coremltools 4.0 with limited success. It works but only if I use an MLMultiArray for the output and covert to an image. Converting to an image takes magnitudes longer than inferencing; making it unusable. If I try to change the MLModel spec to use images for output I get this error running prediction: Failed to convert output Identity to image: NSUnderlyingError=0x2809bad00 {Error Domain=com.apple.CoreML Code=0 "Invalid array shape ( 2048,