Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

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

Open
onemillionbucks opened this issue Aug 11, 2021 · 2 comments
Labels
bug Unexpected behaviour that should be corrected (type)

Comments

@onemillionbucks
Copy link

onemillionbucks commented Aug 11, 2021

🐞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 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 onemillionbucks added the bug Unexpected behaviour that should be corrected (type) label Aug 11, 2021
@dangkhoasdc
Copy link

Using coremltools=3.4 fixes the problem :D .

@onemillionbucks
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Unexpected behaviour that should be corrected (type)
Projects
None yet
Development

No branches or pull requests

2 participants