This is sample code to use Core ML models in Swift Playgrounds. For this code snippet, the MobileNetV2 image classification model and YOLOv3 object detection model are used. The Core ML model files and sample projects for usage in Xcode are provided by Apple. The models can be used to classify images or detect dominant objects in a camera frame or image. You can replace these placeholder models with you own custom models to leverage the power of machine learning inside Swift Playgrounds.
For Core ML models to be used in Playground, combined binary files or the model as well as corresponding model classes are needed. The procedure to obtain them is described below. The compiled binary file needs to be places in the Resources folder or the Playground page, the model class can conveniently be places in a Swift file in the Sources folder of the Playground page.
The Image Classificatio