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.3.0.tar.gz
(7.5 kB
view details)
File details
Details for the file pycoreml-0.3.0.tar.gz.
File metadata
- Download URL: pycoreml-0.3.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69eed55b84edbaf175925df662eb7e39d6f5dfa7feca6b5ab4e400b4b6688784
|
|
| MD5 |
c11911a98c30def1a59a92376fd47358
|
|
| BLAKE2b-256 |
f93661212b6e2a3478fe8df971cffb6b7b845b91dd9e81c3920c3601df9e2f46
|