[SSAConverter] Unable to determine target size for ResizeBilinear
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 850
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 10
Description
## 🐞Describe the bug
- I am trying to convert the my_model.pb model to mlmodel using tfcoreml
- Is this a converter issue? If yes, please specify which converter (tensorflow.)
## Trace
[SSAConverter] [197/239] Converting op type: 'LeakyRelu', name: 'conv_dw_15_3_leaky_relu/LeakyRelu', output_shape: (-1, 256, -1, -1).
[SSAConverter] [198/239] Converting op type: 'Shape', name: 'up_sampling2d_1/Shape', output_shape: (4,).
[SSAConverter] [199/239] Converting op type: 'Conv2D', name: 'conv_pw_15_3/Conv2D', output_shape: (-1, 512, -1, -1).
[SSAConverter] [200/239] Converting op type: 'StridedSlice', name: 'up_sampling2d_1/strided_slice', output_shape: (2,).
[SSAConverter] [201/239] Converting op type: 'BatchNorm', name: 'conv_pw_15_3_bn/FusedBatchNormV3/Add_batch_norm', output_shape: (-1, 512, -1, -1).
[SSAConverter] [202/239] Converting op type: 'Mul', name: 'up_sampling2d_1/mul', output_shape: (2,).
[SSAConverter] [203/239] Converting op type: 'LeakyRelu', name: 'conv_pw_15_3_leaky_relu/LeakyRelu', output_shape: (-1, 512, -1, -1).
[SSAConverter] [204/239] Converting op type: 'ResizeBilinear', name: 'up_sampling2d_1/resize/ResizeBilinear', output_shape: (-1, 128, -1, -1).
Traceback (most recent call last):
File "/Users/opt/anaconda3/envs/py_374/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 58, in
class_labels='/Users/Desktop/saved_model/loto_classes.txt',
File "/Users/opt/anaconda3/envs/py_374/lib/python3.7/site-packages/tfcoreml/_tf_coreml_converter.py", line 691, in convert
custom_shape_functions=custom_shape_functions)
File "/Users/opt/anaconda3/envs/py_374/lib/python3.7/site-packages/coremltools/converters/tensorflow/_tf_converter.py", line 193, in convert
optional_inputs=optional_inputs)
File "/Users/opt/anaconda3/envs/py_374/lib/python3.7/site-packages/coremltools/converters/nnssa/coreml/ssa_converter.py", line 154, in ssa_convert
converter.convert()
File "/Users/opt/anaconda3/envs/py_374/lib/python3.7/site-packages/coremltools/converters/nnssa/coreml/ssa_converter.py", line 578, in convert
convert_func(node)
File "/Users/opt/anaconda3/envs/py_374/lib/python3.7/site-packages/coremltools/converters/nnssa/coreml/ssa_converter.py", line 2193, in _convert_resize_bilinear
raise ValueError('[SSAConverter] Unable to determine target size'
ValueError: [SSAConverter] Unable to determine target size for ResizeBilinear## To Reproduce
- If a python script can reproduce the error, please paste the code snippet
```
# Paste code snippet here
```
import tfcoreml
tfcoreml.convert(
tf_model_path='/Users/Desktop/saved_model/saved_model1.pb',
mlmodel_path='/Users/Desktop/saved_model/test.mlmodel',
input_name_shape_dict={"image_input": [1, 416, 416, 3]},
output_feature_names= ["conv2d_3/BiasAdd","conv2d_8/BiasAdd","conv2d_13/BiasAdd"],
image_input_names="image_input",
red_bias=-1,
green_bias=-1,
blue_bias=-1,
image_scale=2.0 / 255.0,
minimum_ios_deployment_target='13',
class_labels='/Users/Desktop/saved_model/classes.txt',
)
## System environment (please complete the following information):
- coremltools version (3.2):
- Tensorflow version (1.14.0)
- OS (MacOS):
- How you install python (anaconda):
- python version (3.7):
- any other relevant information:
- e.g. keras version 2.0.1
- tfcoreml version 1.1
## Additional context
We tried using coremltools 3.1 and 3.3 and also with tensorflow 1.15 and 2.2 and have the same issue .
we also tried TF OP "ResizeNearestNeighbor" which is involved by keras UpSampling2D layer with default "interpolation='nearest'" option then tried to change the interpolation method to 'bilinear' to see if it's ok for the CoreML convert tool but it didn't work as well.
Contributor guide
Research direction
Start with coremltools/converters/nnssa/coreml/ssa_converter.py, especially _convert_resize_bilinear, and reproduce the failure through tfcoreml.convert using the provided input shape and model details. Compare the ResizeBilinear trace with the converter's target-size handling; done means the reported model converts without the target-size error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- devtools, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100