Skip to main content

Minimal-size Keras model inference library in Rust

Project description

Pocket Inference


A lightweight Rust library for running Keras models without the TensorFlow stack.

CI License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pocket_inference-0.1.0.tar.gz (33.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ x86-64

pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ ARM64

pocket_inference-0.1.0-cp37-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

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

Hashes for pocket_inference-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9bf5a0cf6cc29c863f4911a71f17ee4f4c11a961796e987f66e9a723fb4e6f0
MD5 e3bc388a8f785c4aa6a712f393bc07d5
BLAKE2b-256 73afbc5c4a8521db2f79cc0e5021895f6d11fc0d748ec767ba7bc44723c5c599

See more details on using hashes here.

Provenance

The following attestation bundles were made for pocket_inference-0.1.0.tar.gz:

Publisher: release.yml on James-Wirth/pocket-inference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e76e739eefe6691d2f17dd7536ef26e16a425d70dc706ffe036ce613de9c7b0
MD5 c2d9a188e90b70dac55658c10bf6a84c
BLAKE2b-256 e2db1b89d93ca21d218a55e66dd66a1a9ebf52dd6f7ad099916130f7216ad14f

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pocket_inference-0.1.0-cp37-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 33506e26ec26f9d51b57afd073b05b38a8b963aebbb24bc77a08ac0b26964cc1
MD5 e24139ed28c87cd9e6119bea2cc5cd98
BLAKE2b-256 aaac907e326849aab720077240400e5efdb1efb7510257b5a0fb781167406d96

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pocket_inference-0.1.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pocket_inference-0.1.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e652ff7ed6dc8e9c362b7710975142e4694443a2a0feb7b5a901f8c20ed80b1
MD5 2b6f6d28a63abab28029d1df44916c34
BLAKE2b-256 1943959474ac99c082b6841432340d1a2bb4eaab38a7b2f033b705b4416b7b33

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page