Home » Deploy CoreML Fashions on the Server with Vapor | by Drew Althage | Nov, 2023

Deploy CoreML Fashions on the Server with Vapor | by Drew Althage | Nov, 2023

by Icecream
0 comment

Recently, at Sovrn, we had an AI Hackathon the place we had been inspired to experiment with something associated to machine studying. The Hackathon yielded some improbable tasks from throughout the corporate. Everything from SQL question turbines to chatbots that may reply questions on our merchandise and different unimaginable work. I assumed this might be an excellent alternative to be taught extra about Apple’s ML instruments and perhaps even construct one thing with actual enterprise worth.

A number of of my colleagues and I teamed as much as play with CreateML and CoreML to see if we might combine some ML performance into our iOS app. We received a mannequin skilled and built-in into our app in a number of hours, which was fairly wonderful. But we shortly realized that we had just a few issues to resolve earlier than we might truly ship this factor.

  • The mannequin was hefty. It was about 50MB. That’s lots of house to take up in our app bundle.
  • We wished to replace the mannequin with out releasing a brand new app model.
  • We wished to make use of the mannequin within the net browser as properly.

We didn’t have time to resolve all of those issues. But the opposite day I used to be exploring the Vapor net framework and the thought hit me, “Why not deploy CoreML fashions on the server?”

Apple supplies just a few pre-trained fashions, so at this time we’ll deploy a picture classification mannequin on the server behind a REST API with Vapor and create a SwiftUI consumer to devour it.

This prototype is simply that, a prototype. It’s not meant to be a production-ready answer. It’s meant to be a proof of idea. There might be warnings within the console, and the code gained’t be very clear, however it can work and hopefully get your wheels turning.

If you need to skip all this, or should you do need to comply with alongside, you could find the supply code for this undertaking on GitHub.

Okay, disclaimers over. Let’s get began!

  • Xcode 15
  • macOS 14
  • Homebrew
  • Apple Developer Account + Physical Device for testing

You may also like

Leave a Comment