Minimal-size Keras model inference library in Rust
Project description
A lightweight Rust library for running Keras models without the TensorFlow stack.
Binary size: ~450 KB · Designed for resource-constrained environments
Features
| Category | Supported |
|---|---|
| Layers | Dense, Conv2D, Flatten, MaxPooling2D, AveragePooling2D, Dropout, BatchNormalization |
| Activations | ReLU, Softmax, Sigmoid, Tanh, Linear |
Installation
Rust
Add to your Cargo.toml:
[dependencies]
pocket-inference = "0.1.0"
Python
Install via pip (after building):
pip install maturin
maturin develop --release --features python
Usage
Python
import numpy as np
import pocket_inference as pi
# Load a saved Keras model
model = pi.Sequential.load("model.keras")
# Run inference
input_data = np.array([[1.0, 2.0, 3.0, 4.0]], dtype=np.float32)
output = model.predict(input_data)
print(f"Output: {output}")
# Batch inference
batch_input = np.random.randn(32, 4).astype(np.float32)
batch_output = model.predict(batch_input)
Rust
use pocket_inference::{Sequential, Tensor};
fn main() -> pocket_inference::Result<()> {
// Load a saved Keras model
let model = Sequential::load("model.keras")?;
// Run inference
let input = Tensor::from_vec(vec![1.0, 2.0, 3.0, 4.0], &[4])?;
let output = model.predict(&input)?;
println!("Output: {:?}", output.to_vec());
Ok(())
}
Building from Source
# Clone the repository
git clone https://github.com/James-Wirth/pocket-inference.git
cd pocket-inference
# Build Rust library
cargo build --release
# Build Python bindings
maturin build --release --features python
# Install Python package locally
maturin develop --features python
Roadmap
- Additional layer types (LSTM, GRU, ...)
- More activation functions (LeakyReLU, ELU, GELU, ...)
- GPU acceleration via compute shaders
- Model optimization and pruning tools
- Benchmark suite and performance metrics
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 pocket_inference-0.1.0.tar.gz.
File metadata
- Download URL: pocket_inference-0.1.0.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9bf5a0cf6cc29c863f4911a71f17ee4f4c11a961796e987f66e9a723fb4e6f0
|
|
| MD5 |
e3bc388a8f785c4aa6a712f393bc07d5
|
|
| BLAKE2b-256 |
73afbc5c4a8521db2f79cc0e5021895f6d11fc0d748ec767ba7bc44723c5c599
|
Provenance
The following attestation bundles were made for pocket_inference-0.1.0.tar.gz:
Publisher:
release.yml on James-Wirth/pocket-inference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pocket_inference-0.1.0.tar.gz -
Subject digest:
f9bf5a0cf6cc29c863f4911a71f17ee4f4c11a961796e987f66e9a723fb4e6f0 - Sigstore transparency entry: 1278755040
- Sigstore integration time:
-
Permalink:
James-Wirth/pocket-inference@549db5d2c37a975363d5a4bf907ad8113a71facf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/James-Wirth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@549db5d2c37a975363d5a4bf907ad8113a71facf -
Trigger Event:
push
-
Statement type:
File details
Details for the file pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.7+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e76e739eefe6691d2f17dd7536ef26e16a425d70dc706ffe036ce613de9c7b0
|
|
| MD5 |
c2d9a188e90b70dac55658c10bf6a84c
|
|
| BLAKE2b-256 |
e2db1b89d93ca21d218a55e66dd66a1a9ebf52dd6f7ad099916130f7216ad14f
|
Provenance
The following attestation bundles were made for pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on James-Wirth/pocket-inference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
6e76e739eefe6691d2f17dd7536ef26e16a425d70dc706ffe036ce613de9c7b0 - Sigstore transparency entry: 1278755335
- Sigstore integration time:
-
Permalink:
James-Wirth/pocket-inference@549db5d2c37a975363d5a4bf907ad8113a71facf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/James-Wirth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@549db5d2c37a975363d5a4bf907ad8113a71facf -
Trigger Event:
push
-
Statement type:
File details
Details for the file pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.7+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33506e26ec26f9d51b57afd073b05b38a8b963aebbb24bc77a08ac0b26964cc1
|
|
| MD5 |
e24139ed28c87cd9e6119bea2cc5cd98
|
|
| BLAKE2b-256 |
aaac907e326849aab720077240400e5efdb1efb7510257b5a0fb781167406d96
|
Provenance
The following attestation bundles were made for pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release.yml on James-Wirth/pocket-inference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
33506e26ec26f9d51b57afd073b05b38a8b963aebbb24bc77a08ac0b26964cc1 - Sigstore transparency entry: 1278755148
- Sigstore integration time:
-
Permalink:
James-Wirth/pocket-inference@549db5d2c37a975363d5a4bf907ad8113a71facf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/James-Wirth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@549db5d2c37a975363d5a4bf907ad8113a71facf -
Trigger Event:
push
-
Statement type:
File details
Details for the file pocket_inference-0.1.0-cp37-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pocket_inference-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e652ff7ed6dc8e9c362b7710975142e4694443a2a0feb7b5a901f8c20ed80b1
|
|
| MD5 |
2b6f6d28a63abab28029d1df44916c34
|
|
| BLAKE2b-256 |
1943959474ac99c082b6841432340d1a2bb4eaab38a7b2f033b705b4416b7b33
|
Provenance
The following attestation bundles were made for pocket_inference-0.1.0-cp37-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on James-Wirth/pocket-inference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pocket_inference-0.1.0-cp37-abi3-macosx_11_0_arm64.whl -
Subject digest:
8e652ff7ed6dc8e9c362b7710975142e4694443a2a0feb7b5a901f8c20ed80b1 - Sigstore transparency entry: 1278755461
- Sigstore integration time:
-
Permalink:
James-Wirth/pocket-inference@549db5d2c37a975363d5a4bf907ad8113a71facf -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/James-Wirth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@549db5d2c37a975363d5a4bf907ad8113a71facf -
Trigger Event:
push
-
Statement type: