coremltools icon indicating copy to clipboard operation
coremltools copied to clipboard

Errors when doing inference with compiled model.

Open lee101 opened this issue 2 years ago • 1 comments

🐞Describing the bug

  • Errors running a model with image input and grayscale image output passing the same shapes in (but using numpy array as runtime input) e.g. passing a (1, 3, 512, 512) image in and expecting a (1, 1, 512, 512) grayscale image out.

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 <module>
    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

lee101 avatar Nov 09 '23 06:11 lee101

Can you give us steps to reproduce this issue?

TobyRoseman avatar Nov 13 '23 21:11 TobyRoseman