Search code examples
iosreact-nativemachine-learningcoremlmlmodel

How to reduce a Core ML Model for an iOS app?


I have a model that's almost 500mb that a client wants to implement into their iOS app. HOW IN THE WORLD is a model like this implemented, with it being the size it is? It seems to be a fairly popular model, but there is no documentation or posts anywhere of people actually using the model in a mobile app. Is there such thing as hosting the model somewhere and pointing the client to the server hosting the model? Any options to compress the model? Would love to hear what you've done to solve this issue.

The model is found here: https://coreml.store/cnnemotions


Solution

  • People doing academic research on deep learning / computer vision often use VGG16 or VGG19 as their base model because it's simple and works well. Unfortunately it also has over 100 million parameters, making it unsuitable for use on mobile.

    The solution here is to re-architect the model using a smaller feature extractor such as MobileNet or SqueezeNet, and train it again. Now you'll end up with a model that is much smaller, between 10 and 20 MB.

    This does mean you can't just grab models off of the Internet and convert them to Core ML and expect them to work well. It requires a bit more work than that!