Skip to content

v1.1.0

Latest

Choose a tag to compare

@schappim schappim released this 04 Sep 22:29
· 2 commits to master since this release

Core ML CLI v1.1.0

coreml serve — run a model as a local HTTP API

The model is compiled and loaded once at startup and stays warm, so requests skip the model-loading cost that a fresh coreml predict pays every time. That makes a Core ML model callable from any language, not just the shell.

coreml serve MobileNetV2.mlmodel
curl -X POST -H 'Content-Type: image/jpeg' --data-binary @photo.jpg \
  'http://127.0.0.1:8080/v1/predict?top=3'
  • GET /health · GET /v1/info · POST /v1/predict
  • Input as raw bytes, a multipart/form-data upload (curl -F file=@photo.jpg), or JSON
  • Multi-input models are reachable for the first time. coreml predict feeds one file to the model, so a model with several inputs could not be driven from the CLI at all. Now:
    curl -X POST -H 'Content-Type: application/json' \
      -d '{"inputs": {"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.2}}' \
      http://127.0.0.1:8080/v1/predict
  • ?top=N trims classifier dictionaries and adds an ordered ranked array, since JSON objects carry no ordering
  • Binds loopback by default. --api-key, --cors, --allowed-host, --concurrency, --max-body-mb for anything wider
  • The startup banner prints a curl line matching your model's own input type, so the first request is a copy-paste

Fixed

  • Image prediction was ~6x slower than it needed to be. A CIContext was built for every prediction; creating one sets up a GPU pipeline and cost far more than the render it was made for. 40 images through coreml batch went from 2905 ms to 465 ms. Affects predict and batch, not just serve.
  • coreml meta set --output could delete the model it was editing. The destination was removed before the source was copied into it, with nothing checking the two were different, so an --output naming the source erased it. Now refused, and the clone is staged and swapped in only after the write succeeds.
  • Multi-array outputs were truncated at 100 elements, so JSON results from embedding models silently lost data.
  • A JSON tensor that did not match the model's input shape was silently truncated or left partly uninitialised, producing garbage predictions. Now an error naming both counts. Non-numeric values in a tensor are rejected rather than dropped.

Changed

  • swift-argument-parser 1.7.1 → 1.8.2
  • CI and Dependabot configured for the repository
  • Test suite grown from 105 to 212 tests

Requirements

  • macOS 13.0 or later
  • Apple Silicon or Intel Mac (the binary is universal)

Installation

Homebrew

brew tap schappim/coreml-cli
brew install coreml-cli

Manual

tar -xzf coreml-1.1.0-macos.tar.gz
sudo cp coreml /usr/local/bin/