Why am I getting the error: p roblem decoding CoreML document?

I am using CoreML with Swift 4.0 on beta version of Xcode 9.

If you select the VGG16.mlmodel file in the project navigator, I get the error message: There was an problem decoding this document CoreML

In addition, as a result of the code, I get the errors of Use of unresolved identifier 'VGG16' and Use of undeclared type 'VGG16'

VGG16.mlmodel downloaded here https://developer.apple.com/machine-learning/

What could be the problem?

PS for models Places205-GoogLeNet, ResNet50 and Inception v3 everything works fine.

+7
swift4 xcode9 coreml
source share
3 answers

As already mentioned, I will answer my comment in response.

Others mentioned this, but you most likely have a damaged boot or something is broken with the model itself. For starters, I highly recommend not using the VGG16 model or related models on a mobile device just because of their sheer size (500 MB for VGG16). You will run out of memory on the iPhone 6 just by loading the model, the size of your application will be gigantic, and you will have a long initialization time as you load these scales.

I recommend using something like the SqueezeNet option, which is small (~ 5 MB), can be more accurate when training on ImageNet, and not as expensively calculated as the Inception family. Apple refers to the use of one of them in one of the Main ML WWDC sessions.

When you add a model to your Xcode project, make sure that it is actually registered for your purpose. The current beta version of Xcode sometimes forgets to add this to your goal, so select the model and check the file inspector to make sure it is part of your target. If the model is not your goal, Xcode will not automatically generate a Swift header for it.

+8
source share
  • ./setup.sh
  • select target for VGG16.mlmodel , see this screenshot
+1
source share

I get the same for a model that has Dropout on it. Try removing these layers by copying the scales to a new model without them.

0
source share

All Articles