I convert a pytorch model to mlmodel
with a custom layer, and create a test app in swift
to test my model. When i implement the custom layer by swift
, it works well. However when i implement the custom layer by object-C
, the code return
2022-01-14 17:58:49.964377+0800 CustomLayers[2547:968723] [coreml] Error in adding network -1.
2022-01-14 17:58:49.965023+0800 CustomLayers[2547:968723] [coreml] MLModelAsset: load failed with error Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}
2022-01-14 17:58:49.965085+0800 CustomLayers[2547:968723] [coreml] MLModelAsset: modelWithError: load failed with error Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}: file CustomLayers/model_2.swift, line 114
2022-01-14 17:58:49.966267+0800 CustomLayers[2547:968723] Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.apple.CoreML Code=0 "Error in declaring network." UserInfo={NSLocalizedDescription=Error in declaring network.}: file CustomLayers/model_2.swift, line 114
(lldb)
It seems the model load failed with object-C
custom layer. So i wonder does object-C
custom layer implementation can't work with swift
project? Although i try to set the CustomLayers-Bridging-Header.h
. It still doesn't work.
System Information
- mac OS: 11.6.1 Big Sur
- xcode: 12.5.1
- coremltools: 5.1.0
- test device: iphone 11