prisma-ai / torch2coreml

Torch7 -> CoreML
MIT License
384 stars 54 forks source link

Cannot use convert-fast-neural-style.py to convert models to CoreML #23

Closed wei20 closed 6 years ago

wei20 commented 6 years ago

Hello, I am using the script given in the example fast-neural-style. Prepare models worked as expected but when it comes to conversion, the error occurred. Don't know how to figure this out.

input: python convert-fast-neural-style.py -input prepared_models/candy.t7 -output coreml_models/candy.mlmodel

output: 2018-01-20 12:58:11.787 python[23363:3203919] +[MLModel compileModelAtURL:error:]: unrecognized selector sent to class 0x7fff460e58e8 Traceback (most recent call last): File "convert-fast-neural-style.py", line 176, in main() File "convert-fast-neural-style.py", line 162, in main unknown_layer_converter_fn=convert_instance_norm File "/Users/vega/workspace/virtualenv/lib/python2.7/site-packages/torch2coreml/_torch_converter.py", line 294, in convert return MLModel(builder.spec) File "/Users/vega/workspace/virtualenv/lib/python2.7/site-packages/coremltools/models/model.py", line 153, in init self.proxy = _get_proxy_from_spec(filename) File "/Users/vega/workspace/virtualenv/lib/python2.7/site-packages/coremltools/models/model.py", line 77, in _get_proxy_from_spec return _MLModelProxy(filename) RuntimeError: Caught an unknown exception!

wei20 commented 6 years ago

I was trapped in this issue for days. All available means could be found have been tried but none of them work out. Today I figured it out by myself, the error was cause by virtualenv. Stop doing it under virtualenv would be fine.