Core ML framework why baked in the bundle - ios

In my limited knowledge of the new Core ML framework, I understand that the model is build in to the bundle.
I was sure that ML and models evolve over time, collecting more data to furthere evolve the model. If that is true, why is the Core ML framework then using "static" models?
I can see that for speed needed for computer vision(object recognition etc.), but the model should be able to evolve reading from http something - right?

CoreML is not made to train the model on the mobile device, but to run a trained model in the app.
It's still true that you might improve your model over time and might want to be able to update it without having to submit a new app.
There has been some discussion on that: https://stackoverflow.com/a/44463680/2054629 and I don't have a real answer on why Apple didn't made easy to update a model as long as it takes the same input and has the same output types.

Related

Does DL4J supports on device model retraining

I am trying to deploy a pretrained model on a android application . Now, the need is to retrain the model with the data captured locally.
Specifically what is happening is, There is a pretrained dnn model which predicts the quality of a video seeing the bandwidth. The neural network was trained on some data which had the bandwidth and the corresponding video quality. Now that model has to be deployed on device for retraining on the new data.
This new data is already captured via a mobile application and is stored in required format(csv) .
First i thought of using tflite but it does not support on device retraining.
Now i am trying to use DL4J but could not understand how to do it.
If it possible to use DL4J in this case then how can i do it.
If not, then is there a another approach.
ps. I have tried my best to write the problem statement clearly. Pardon me, if u find it difficult to understand. Please comment what u have not understood, i will clear it.

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
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!

Is it possible to train a CoreML model on device as the app runs?

Is it possible to ship an iOS app with a CoreML model and then have the app continue improving (training) the model on device based on user behaviour for example? So, then the model would keep growing and improving right on the device with no need of a server support...
It's now possible with Core ML 3.
https://developer.apple.com/videos/play/wwdc2019/704/
Skip to 9:00 to see it in action. If you just want the code, skip to 13:50.
The answer is YES.
Since CoreML 3 is greatly optimised – the answer is YES, you can train a CoreML model on device when your app is running.
However, using CoreML 2 it's not possible to train a model on device, because running CoreML 2 app, considerably much power is required to train a model in comparison with CoreML 3. That's why desktop and cloud computers with power GPUs are used for creating a pre-trained models. In CoreML 2 your MLmodel must be pre-configured and you have to include all pre-processing techniques like Edge Detection or Frame Differencing at that stage.
I'm trying to do the same thing. Apparently, when you convert your model to Core ML format with coremltools, you can pass the "respect_trainable" argument to the converter and it will automatically make the model updatable.

Dynamic Machine Learning Model for iOS

I have an iOS app written in SWIFT. It gets user information and saves it in the database (Firebase). I want to use this data and then dynamically update the Machine Learning model created as the data updates to provide an improved prediction every time. Is there a way of doing this?
I know that I can create my trained model separately (e.g. using TensorFlow) and then use Core ML to import it into my app but how can I do this so the model keeps updating as new data comes in?
Thanks for the help!!
Depends on the model.
You cannot use Core ML for this as it does not support training. The Metal Performance Shaders framework in iOS 11.3 now supports training for neural network-based models. And you can always write your own training code.
If the model is something basic like a logistic regression, you can train it on the device and it won't take that long. If it's a deep learning model with many layers and you're training it on a lot of data, it might not be feasible to train on the device.

Options for in-cloud deep learning iOS

Is there any in-cloud deep-learning solutions that makes data predictions?
For example, user may write some text into text field and algorithm (deep learning code)
should suggest one of 8 categories based on input.
If it suggests wrong variant - user may select correct one, and algorithm should improve itself
in real-time without new app’s release. Also learning model should be shared between users.
Or another example:
User writes some text into field, and algorithm improves that text based on trained input.
Is there are any solutions for that available right now on iOS?
Which is the best for price/value?
Update: CoreML is not an option because it doesn't share model and requires app release to update the model.
It seems to me that what you are looking for can be covered by Core ML, starting in iOS 11.
Here you have 2 links to the WWDC talks:
Introducing Core ML
Core ML in depth
The first step is for you to build a Core ML model.
Hope this helps

Resources