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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycoreml-0.1.0.tar.gz.
File metadata
- Download URL: pycoreml-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fda58082f528b5393abafe51d8aec6c40d5289e4aa90cf7cad102394cadac134
|
|
| MD5 |
b6804fb95ef9bdce97b781ce950d1302
|
|
| BLAKE2b-256 |
e698104501e265a0d8426b22f08c7dbd2b95dbdfcea284ec573cde7a32db00d8
|
File details
Details for the file pycoreml-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pycoreml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f89c7f85d5a2c62f678f1310804463426a0a0d21696d27e066f5cea21fdb7431
|
|
| MD5 |
c2b5e1ca5eebaf26454233a5b281f11d
|
|
| BLAKE2b-256 |
cb33ecb74af4196bcf7d4a1fc7a962667ff42ceaa6ce35383d99c644f1a8a9a1
|