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.1.tar.gz
(7.4 kB
view details)
File details
Details for the file pycoreml-0.2.1.tar.gz.
File metadata
- Download URL: pycoreml-0.2.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a787403d13e6f133009a48854ae43cfc0981ab7ea6c123c0f9604e9b66a77d9
|
|
| MD5 |
d3da422eef41f8abebe7e44e0f93f6b6
|
|
| BLAKE2b-256 |
6d7aeb336fd9bcb61a672e276e742b2eb6d8f94f44cffdcc048076d51664f9d6
|