From the course: Machine Learning in Mobile Applications

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Client tied to a visual recognition model

Client tied to a visual recognition model

From the course: Machine Learning in Mobile Applications

Client tied to a visual recognition model

We now want to implement our image classification model. Once again, the Core ML models will only work on iOS or macOS. Not only that, I found this is one of the weird cases where things do not work on the simulator the way they work on a real device. If you are trying this on the simulator, be aware that the predictions will likely not be accurate. So the code we want to change is in the VisualRecognition ViewModel. And we're going to look for the GetTreeTypeAsync method, which is right here. If we look at the start code of this chapter, we can see that there's a couple of new methods for dealing with images in iOS. And they require you to get images we want to test in a format that the model expects. So we've already got this in here, so we've got this "# iOS" here that's going in and pulling up these images in the correct format that iOS expects. So this is going to be another example of code that we really only want to run on iOS. So we're going to use "#if __iOS__". And we'll do…

Contents