onnx-coreml icon indicating copy to clipboard operation
onnx-coreml copied to clipboard

"from onnx_coreml import convert" Causes Missing Module Error "No module named 'coremltools.converters.nnssa'"

Open onemillionbucks opened this issue 4 years ago • 2 comments

🐞Describe the bug

I have tried the virtual environment and in my main environment. "from onnx-coreml import convert" causes the problem

Trace

If applicable, please paste the error trace.

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-21-ccd67624943f> in <module>
      2 from onnx import onnx_pb
      3 import torch
----> 4 from onnx_coreml import convert
      5 model_in = "guassianMaskversion11.onnx"
      6 model_out = "gMaskfrom_onnx11.mlmodel"

~/opt/anaconda3/lib/python3.8/site-packages/onnx_coreml/__init__.py in <module>
      4 from __future__ import unicode_literals
      5 
----> 6 from .converter import convert
      7 
      8 # onnx-coreml version

~/opt/anaconda3/lib/python3.8/site-packages/onnx_coreml/converter.py in <module>
     33 
     34 # ML model passes
---> 35 from coremltools.converters.nnssa.coreml.graph_pass.mlmodel_passes import remove_disconnected_layers, transform_conv_crop
     36 
     37 from ._error_utils import ErrorHandling

ModuleNotFoundError: No module named 'coremltools.converters.nnssa'

To Reproduce

  • I ran this code in the virtual environment and outside of it. the error happens on the "from onnx_coreml import convert" line.
import sys
from onnx import onnx_pb
from onnx_coreml import convert

model_in = sys.argv[1]
model_out = sys.argv[2]

model_file = open(model_in, 'rb')
model_proto = onnx_pb.ModelProto()
model_proto.ParseFromString(model_file.read() )
coreml_model = convert(model=model_proto,
                       image_input_names=['input'], 
                       image_output_names=['input'])



coreml_model.save(model_out)

  • If applicable, please attach ONNX model
    • If model cannot be shared publicly, please attach it via filing a bug report at https://developer.apple.com/bug-reporting/
  • If model conversion succeeds, however, there is numerical mismatch between the original and the coreml model, please paste python script used for comparison (pytorch code, onnx runtime code etc.)

System environment (please complete the following information):

  • coremltools version (e.g., 3.0b5): 4.1
  • onnx-coreml version (e.g. 1.0b2): 1.3
  • OS (e.g., MacOS, Linux): MacOS
  • macOS version (if applicable): 11.2.3
  • How you install python (anaconda, virtualenv, system):
  • python version (e.g. 3.7): 3.8.8
  • any other relevant information: I followed the example step by step including the virtual environment setup. I even looked and found this "coremltools.converters.nnssa" on this repository so I dont know why it says it is missing.

Additional context

Add any other context about the problem here.

onemillionbucks avatar Aug 11 '21 23:08 onemillionbucks

Using coremltools=3.4 fixes the problem :D .

dangkhoasdc avatar Nov 29 '21 15:11 dangkhoasdc

Thanks, I haven't tried this out because I solved the problem my problem different way (rolling back numpy version), but thank you.

onemillionbucks avatar Jan 12 '22 17:01 onemillionbucks