--- id: sbi4onnx version: "1.0.7" license: MIT License license_treatment: permissive maintenance: dormant --- # sbi4onnx — A very simple script that only initializes the batch size of ONNX. Simple Batchsize Initialization for ONNX. License: permissive · Maintenance: dormant · Downloads: 82.7K/mo ## 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 above — 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 pip install sbi4onnx uv add sbi4onnx poetry add sbi4onnx ## Installing 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_current - Install friction: low - Maintenance: dormant - Downloads: 82.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags onnx batch size initialization, modify onnx model batch dimension, onnx dynamic batch size, onnx model preprocessing, batch size converter onnx, onnx graph modification, variable batch onnx, onnx-tools, model-optimization [View on SkillFed](https://skillfed.io/packages/sbi4onnx) · [View on PyPI](https://pypi.org/project/sbi4onnx/)