CoreML inference from Python — powered by Swift & ApplePy
Project description
PyCoreML
CoreML inference from Python — powered by Swift & ApplePy.
Direct access to Apple's CoreML framework with explicit compute unit selection (CPU, GPU, Neural Engine).
macOS only — requires Swift 6.0+ toolchain
Install
pip install -e .
Usage
import pycoreml
# Load and describe a model
info = pycoreml.load_model("/path/to/model.mlmodelc")
desc = pycoreml.model_description("/path/to/model.mlmodelc")
# Run prediction
result = pycoreml.predict("/path/to/model.mlmodelc", {"x": 42.0})
# Predict with explicit compute unit (the killer feature)
result = pycoreml.predict_with_options(
"/path/to/model.mlmodelc",
{"x": 42.0},
"cpuAndNeuralEngine" # or "cpuOnly", "cpuAndGPU", "all"
)
API
| Function | Returns | Description |
|---|---|---|
load_model(path) |
str |
Load model and return description |
model_description(path) |
dict[str, str] |
Model metadata |
predict(path, inputs) |
dict[str, float] |
Run inference |
list_compute_units() |
list[str] |
Available compute units |
predict_with_options(path, inputs, unit) |
dict[str, float] |
Predict with compute unit control |
Examples
See pycoreml/examples/demo.py for a full demo.
License
BSD-3-Clause © Jagtesh Chadha — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycoreml-0.2.0.tar.gz
(7.2 kB
view details)
File details
Details for the file pycoreml-0.2.0.tar.gz.
File metadata
- Download URL: pycoreml-0.2.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a533bc56329682941633f72820240fb29ee4888537aeb88fd833ed7a4333dc7
|
|
| MD5 |
7e7fc7971ded3e590d7bdf12cc5f58bd
|
|
| BLAKE2b-256 |
82483efb245484d9874a6d231838fce43d5d9be04555aaac70b98894c5cefc77
|