skillfed

onnxslim

OnnxSlim: A Toolkit to Help Optimize Onnx Model

onnxslim v0.1.95 1.3M downloads/30d#4,117 on PyPI513
Permissive license MIT Active released

What it is and what it does

OnnxSlim is a toolkit for optimizing ONNX neural network models by reducing operator count and model size while maintaining inference accuracy. It provides both a command-line interface and a Python API for model optimization. The package depends on onnx for model handling, sympy for symbolic computation, ml-dtypes for numeric types, packaging for version management, and colorama for terminal output formatting.

The tool is designed for developers deploying neural networks who need faster inference without sacrificing model accuracy. It integrates into major ML frameworks and deployment pipelines, having been adopted by NVIDIA TensorRT-Model-Optimizer, HuggingFace optimum and transformers.js, ultralytics, and others. Installation is straightforward via pip with no compiled dependencies.

Use it for:

  • Optimize ONNX models for edge deployment where model size and inference latency are critical constraints.
  • Reduce inference latency in production serving pipelines while maintaining model accuracy.
  • Prepare pre-trained models for mobile or embedded inference with lower computational overhead.
  • Integrate model optimization into automated ML pipelines as a preprocessing step before deployment.
  • Benchmark and compare inference performance before and after optimization on target hardware.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

OnnxSlim reduces the size and operator count of ONNX models while preserving accuracy and improving inference speed through optimization techniques.

Yes. OnnxSlim is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and installs with low friction. It is widely adopted in production ML frameworks (NVIDIA, HuggingFace, ultralytics) and has strong community adoption. Install if you work with ONNX models and need to optimize for speed or size.

Install

onnxslim on PyPI

pip

pip install onnxslim

uv

uv add onnxslim

poetry

poetry add onnxslim

Installing onnxslim

Before you install

Low friction installation with a pure Python wheel. Actively maintained with a release in the last two weeks and a recent commit history. Five runtime dependencies are all stable, widely-used packages.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.

Quickstart

pip install onnxslim

import onnx
import onnxslim

model = onnx.load("model.onnx")
slimmed_model = onnxslim.slim(model)
if slimmed_model:
    onnx.save(slimmed_model, "slimmed_model.onnx")

Requires Python 3.8 or later. Input must be a valid ONNX model file.

Verify before relying

  • Specific optimization techniques used (pruning, quantization, graph simplification, or others)
  • Whether accuracy preservation is measured quantitatively or qualitatively
  • Inference speed improvements are claimed but not quantified in the excerpt

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 5 — colorama, ml-dtypes, onnx, packaging, sympy
Maintenance actively maintained — 13 days since the last release
Last repo commit
First released
Downloads 1,281,234/month — #4,117 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: onnxslim-0.1.95-py3-none-any.whl

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

onnx model optimizationreduce onnx model sizeonnx inference speedmodel compression onnxslim onnx modelsonnx operator reductionlightweight onnx inference
model-optimizationonnxinference-performance

More Artificial Intelligence packages