apple / coremltools

Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
https://coremltools.readme.io
BSD 3-Clause "New" or "Revised" License
4.45k stars 647 forks source link

Errors when doing inference with compiled model. #2049

Open lee101 opened 1 year ago

lee101 commented 1 year ago

🐞Describing the bug

II tried both mlprogram and neuralnetwork when compiling MODNet but keep getting these errors

Stack Trace

/usr/local/lib/python3.11/site-packages/coremltools/models/model.py:154: RuntimeWarning: You will not be able to run predict() on this Core ML model. Underlying exception message was: Error compiling model: "compiler error: Encountered an error while compiling a neural network model: validator error: Model image output 'pred_matte' has a different shape than its corresponding return value to main.". _warnings.warn( Traceback (most recent call last): File "/Users/leepenkman/code/MODNet/onnx/inference_coreml.py", line 102, in result = model.predict({"img": im}) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/coremltools/models/model.py", line 632, in predict raise self._framework_error File "/usr/local/lib/python3.11/site-packages/coremltools/models/model.py", line 152, in _get_proxy_and_spec return _MLModelProxy(filename, compute_units.name), specification, None ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Error compiling model: "compiler error: Encountered an error while compiling a neural network model: validator error: Model image output 'pred_matte' has a different shape than its corresponding return value to main.".

Paste Python code snippet here, complete with any required import statements.


model conversion succeeded but then when i go to do inference on the model i get these errors.

## System environment (please complete the following information):
 - coremltools version:
 - OS (e.g. MacOS version or Linux type): happening on MacOS/latest pytorch/coremltools
 - Any other relevant version information (e.g. PyTorch or TensorFlow version):

any pointers would be really appreciated
TobyRoseman commented 1 year ago

Can you give us steps to reproduce this issue?