try converting onnx model to coreml and testing it with a batch size of 1, which doesn't work
$ python broken_convert.py
output:
WARNING:root:TensorFlow version 2.0.0 detected. Last version known to be fully compatible is 1.14.0 .
1/14: Converting Node Type ConvTranspose
2/14: Converting Node Type BatchNormalization
3/14: Converting Node Type Relu
4/14: Converting Node Type ConvTranspose
5/14: Converting Node Type BatchNormalization
6/14: Converting Node Type Relu
7/14: Converting Node Type ConvTranspose
8/14: Converting Node Type BatchNormalization
9/14: Converting Node Type Relu
10/14: Converting Node Type ConvTranspose
11/14: Converting Node Type BatchNormalization
12/14: Converting Node Type Relu
13/14: Converting Node Type ConvTranspose
14/14: Converting Node Type Tanh
Translation to CoreML spec completed. Now compiling the CoreML model.
Model Compilation done.
Traceback (most recent call last):
File "convert.py", line 19, in <module>
pred_coreml = mlmodel.predict(input_dict, useCPUOnly=True)
File "/Users/bilal/miniconda3/envs/pytorch/lib/python3.7/site-packages/coremltools/models/model.py", line 334, in predict
return self.__proxy__.predict(data, useCPUOnly)
RuntimeError: {
NSLocalizedDescription = "Shape (1 x 100 x 1 x 1) was not in enumerated set of allowed shapes";
}
Try converting onnx model to coreml and testing it with a batch size of 64, which does work
$ python working_convert.py
output:
WARNING:root:TensorFlow version 2.0.0 detected. Last version known to be fully compatible is 1.14.0 .
1/14: Converting Node Type ConvTranspose
2/14: Converting Node Type BatchNormalization
3/14: Converting Node Type Relu
4/14: Converting Node Type ConvTranspose
5/14: Converting Node Type BatchNormalization
6/14: Converting Node Type Relu
7/14: Converting Node Type ConvTranspose
8/14: Converting Node Type BatchNormalization
9/14: Converting Node Type Relu
10/14: Converting Node Type ConvTranspose
11/14: Converting Node Type BatchNormalization
12/14: Converting Node Type Relu
13/14: Converting Node Type ConvTranspose
14/14: Converting Node Type Tanh
Translation to CoreML spec completed. Now compiling the CoreML model.
Model Compilation done.
(64, 3, 64, 64)
❓DCGAN generator only accepts batches of 64
System Information
Code
model.py
broken_convert.py
working_convert.py
Reproduce
convert pytorch model to onnx
try converting onnx model to coreml and testing it with a batch size of 1, which doesn't work
output:
Try converting onnx model to coreml and testing it with a batch size of 64, which does work
output: