This is a prototype project to demonstrate one way to deploy CoreML models on the server with Vapor. It is not intended for production use.
This project demonstrates one way how to deploy a CoreML model on the server with Vapor. The project includes a simple Vapor server that accepts images and returns a prediction using a CoreML model. The model is a pre-trained Resnet50 model. The server uses this to classify the primary subject of images uploaded to the server.
- Server - Vapor server with CoreML model, and Dockerfile
- SwiftUI iOS client
- Xcode 15 (client)
- Swift 5.5
- Clone repo
- Open terminal and navigate to the project directory
- Open the project with Xcode.
xed .
cd server && swift run App serve
- Back in Xcode, set the development team in
Signing & Capabilities
to your own team/profile - Select the
Run
scheme of your choice and run the project in Xcode - On simulator, select
Photo Library
then one of the default images, thenUpload Image
- Get results!
NOTE: additional steps may (most likely will) be required to run the project on a physical device. see The Serve Command about binding to host and port.
Source code for the article Deploy CoreML Models on the Server with Vapor