Cannot convert TF2.0 model to CoreML
- 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 TensorFlow model in this [repo](https://github.com/PeterL1n/BackgroundMattingV2-TensorFlow) to Core ML.
## Trace
```
Running TensorFlow Graph Passes: 100%|██████████| 5/5 [00:00<00:00, 6.28 passes/s]
Converting Frontend ==> MIL Ops: 96%|█████████▋| 848/880 [00:03<00:00, 277.53 ops/s]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
3
4
----> 5 coreml_model = ct.convert(model, inputs=[input_image1, input_image2], minimum_ios_version="13")
14 frames
/usr/local/lib/python3.7/dist-packages/coremltools/converters/mil/mil/builder.py in _add_const(cls, val, name, before_op)
73 def _add_const(cls, val, name, before_op):
74 if not is_python_value(val):
---> 75 raise ValueError("Cannot add const {}".format(val))
76 if any_symbolic(val):
77 msg = (
ValueError: Cannot add const [is3, 1, 5, 1, 1]
```
## To Reproduce
Use this [Colab notebook](https://colab.research.google.com/drive/19r7ovP5qn_Tc67-4UeAq-mEOTLZaKfJ1?usp=sharing
) to reproduce the error.
The weights of the PyTorch model are in [google drive](https://drive.google.com/file/d/1b2FQH0yULaiBwe4ORUvSxXpdWLipjLsI/view)
Contributor guide
Research direction
Start with the linked Colab notebook and reproduce the failure in the TensorFlow conversion path, focusing on the ValueError for `[is3, 1, 5, 1, 1]`. Compare the conversion inputs and model sources linked in the issue, and consider the work complete when the model converts without this error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch, tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100