sbi4onnx
A very simple script that only initializes the batch size of ONNX. Simple Batchsize Initialization for ONNX.
What it is and what it does
sbi4onnx is a lightweight command-line and Python tool for modifying ONNX neural network models to change their batch size dimension. It reads an ONNX file, replaces the batch dimension (typically the first dimension) with a string you specify—such as 'N' for a named dynamic dimension, '-1' for a wildcard, or any custom identifier—and writes the modified model to disk. The tool optionally runs ONNX simplification on the result to clean up redundant operations.
The package is designed for a narrow, specific task: preparing pre-trained models for inference frameworks that require explicit batch size handling. It is not a general ONNX manipulation library. The documentation warns that it may fail on models with complex internal structures, particularly those containing Reshape operations that already have undefined dimensions or Gemm layers with non-unit batch outputs. For such cases, the author recommends pre-processing with a companion tool (sam4onnx) to fix problematic dimensions first.
Use it for:
- Convert a fixed-batch ONNX model (e.g., batch size 1) to accept variable batch sizes for deployment.
- Prepare ONNX models for TensorRT or other inference engines that require explicit batch dimension naming.
- Batch-process multiple ONNX files to standardize their batch dimension representation before model serving.
- Replace hardcoded batch dimensions with symbolic names for dynamic batching in production inference pipelines.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Modifies ONNX model files to initialize or replace their batch size dimension with a specified value, useful for making models accept variable or fixed batch sizes.
Yes, if you need to modify ONNX batch dimensions and your models have straightforward graph structures. The tool is lightweight, dependency-free at runtime, and MIT-licensed. However, maintenance is dormant (last update 808 days ago), so expect no active bug fixes or feature development. Test thoroughly on your specific models first, as the tool explicitly does not handle complex Reshape or Gemm patterns—if your model fails, you may need to preprocess it with other tools or edit the ONNX file manually.
Install
sbi4onnx on PyPI
pip
pip install sbi4onnxuv
uv add sbi4onnxpoetry
poetry add sbi4onnxInstalling sbi4onnx
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant—last release was 808 days ago, though the repository remains active with recent commits as of 2024-05-28.
License in practice
MIT License permits commercial and private use with minimal restrictions, making it safe to adopt in most projects.
Quickstart
pip install sbi4onnx
from sbi4onnx import initialize
onnx_graph = initialize(
input_onnx_file_path="model.onnx",
output_onnx_file_path="model_Nx224x224.onnx",
initialization_character_string="N"
)
Requires onnx and onnx-graphsurgeon to be installed separately; tool may fail on models with complex Reshape operations or multiple undefined dimensions.
Verify before relying
- Whether the tool successfully handles all common ONNX model architectures or primarily works with simpler graph structures.
- Performance impact of running onnxsim simplification on large models during batch size initialization.
- Compatibility with recent ONNX opset versions beyond what the fact sheet indicates.
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 808 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 82,716/month — #14,140 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sbi4onnx-1.0.7-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
soc4onnxChanges the opset version of an ONNX model…
permissive · top 15,000 on PyPI
scc4onnxConverts ONNX model input tensor dimensions and…
permissive · top 15,000 on PyPI
sio4onnxModifies the input and output shapes of ONNX…
permissive · top 15,000 on PyPI
ssi4onnxInfers and fills missing tensor shape…
permissive · top 15,000 on PyPI
sng4onnxAutomatically generates and assigns operation…
permissive · top 15,000 on PyPI
sor4onnxRenames input, output, and operator nodes in…
permissive · top 15,000 on PyPI
svs4onnxSwaps connections between output and input…
permissive · top 15,000 on PyPI
sde4onnxRemoves embedded doc_strings from ONNX model…
permissive · top 15,000 on PyPI
simple-onnx-processing-toolsA collection of command-line tools for…
permissive · top 15,000 on PyPI
lamindb_setupConfigures and initializes LaminDB instances,…
unclear · top 15,000 on PyPI