A tool that removes image backgrounds, usable as a CLI, Python library, HTTP server, or Docker container.
inisis/OnnxSlim
A Python toolkit that optimizes ONNX models by reducing operator count while keeping accuracy, aiming for faster inference.
- Stars
- 521
- Forks
- 44
- Open issues
- 31
- Last commit
- 4 days ago
What is it?
OnnxSlim slims down ONNX models by removing redundant operators, so the resulting graph is smaller and typically runs faster during inference. It can be used from the command line with a single `onnxslim input output` call, or from Python by passing a loaded model to `onnxslim.slim()` and saving the result.
The project is distributed on PyPI as `onnxslim` and can also be installed from source. Its README lists several open-source projects that have adopted it as part of their model export or optimization pipelines, including Ultralytics, Hugging Face Optimum, and transformers.js.
Key features
- 01Reduces the number of operators in an ONNX graph while aiming to preserve accuracy.
- 02Provides a command-line tool for quick model slimming.
- 03Offers a Python API that takes a loaded ONNX model and returns an optimized one.
- 04Installable from PyPI or directly from source.
Use cases
- Reducing the size and operator count of an ONNX model before deploying it with ONNX Runtime.
- Adding an optimization step to a model export pipeline built on PyTorch or similar frameworks.
- Trimming models used in LLM or vision inference workloads.
Quick start
- 1
Install the prebuilt package from PyPI
pip install onnxslim - 2
Slim an ONNX model from the command line
onnxslim your_onnx_model slimmed_onnx_model
Topics
FAQ
- What is OnnxSlim?
- A Python toolkit that optimizes ONNX models by reducing operator count while keeping accuracy, aiming for faster inference. OnnxSlim slims down ONNX models by removing redundant operators, so the resulting graph is smaller and typically runs faster during inference. It can be used from the command line with a single `onnxslim input output` call, or from Python by passing a loaded model to `onnxslim.slim()` and saving the result.
- Is OnnxSlim free to use? What license does it have?
- OnnxSlim is open source under the MIT license. Check the license terms before using it in commercial products.
- Is OnnxSlim still maintained?
- Actively maintained. The last commit to OnnxSlim was on Oct 16, 2026.
- What can I use OnnxSlim for?
- Reducing the size and operator count of an ONNX model before deploying it with ONNX Runtime. Adding an optimization step to a model export pipeline built on PyTorch or similar frameworks. Trimming models used in LLM or vision inference workloads.
- How do I install OnnxSlim?
- Install the prebuilt package from PyPI: pip install onnxslim Slim an ONNX model from the command line: onnxslim your_onnx_model slimmed_onnx_model
- Where can I get OnnxSlim?
- The source code and installation instructions are on GitHub: https://github.com/inisis/OnnxSlim
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Apple's research code that turns a single photo into a 3D Gaussian scene in under a second, renderable as nearby novel views.
A PyTorch-based open-source framework for deep learning on healthcare imaging data, covering preprocessing, networks, losses and evaluation metrics.
A collection of 419 pre-trained AI models covering vision, speech, NLP and LLMs, all runnable from a shared Python CLI via the ailia SDK.
A small educational project for running vision-language model inference on Apple Silicon with MLX, scoring candidate answers about one image.
A free, MIT-licensed course of 542 lessons that builds AI engineering concepts from scratch in Python, TypeScript, Rust and Julia.