--- id: sam4onnx version: "2.0.0" license: MIT License license_treatment: permissive maintenance: aging --- # sam4onnx — A very simple tool to rewrite parameters such as attributes and constants for OPs in ONNX models. Simple Attribute and Constant Modifier for ONNX. License: permissive · Maintenance: aging · Downloads: 83.0K/mo ## What it is and what it does sam4onnx is a lightweight utility for modifying operator attributes and constant inputs in ONNX models. It accepts either a file path to an .onnx model or an in-memory onnx.ModelProto object, locates a specified operator by name, and rewrites its attributes or the constants feeding into it. The tool operates on a single operator at a time and includes support for recursive modification within If operator subgraphs. The package provides both a command-line interface and a Python API. It does not validate the overall graph integrity after modifications—that responsibility falls to the user. It is designed for simple, targeted edits rather than comprehensive model transformation, making it useful for quick parameter adjustments, debugging, or preparing models for deployment with modified hyperparameters. Use it for: - Adjust operator attributes (e.g., transpose permutation, reshape dimensions) in an exported ONNX model without retraining. - Modify constant tensor values feeding into operators to test different hyperparameters or thresholds. - Batch-edit multiple models' parameters via CLI for deployment pipeline automation. - Recursively update parameters in conditional branches (If operators) across a model's subgraph structure. - Prepare quantized or pruned models by rewriting shape metadata or operator-specific configuration. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Rewrites attributes and constants in ONNX model operators via CLI or Python API, supporting both file-based and in-memory graph modifications. Yes, if you need to edit ONNX operator parameters post-export. Low install friction, no dependencies, permissive license, and straightforward API make it a practical choice for model tweaking. Aging maintenance (189 days since last release) is a minor concern but not a blocker for a stable utility tool. Verify that graph-level side effects of your edits are acceptable before relying on it in production pipelines. ## Install pip install sam4onnx uv add sam4onnx poetry add sam4onnx ## Installing sam4onnx Before you install: Low friction: pure Python wheel with no runtime dependencies. Maintenance status is aging—last release 189 days ago—but the repository remains active and targets current Python versions. License in practice: MIT License permits commercial and private use, modification, and distribution with minimal restrictions, making it suitable for most projects. Quickstart: pip install sam4onnx from sam4onnx import modify modified = modify( input_onnx_file_path='model.onnx', output_onnx_file_path='modified.onnx', op_name='Transpose_17', attributes={'perm': [0, 1]} ) Verify before relying: - Whether graph integrity validation is performed after modifications beyond the documented single-OP scope. - Performance characteristics when working with large models or deeply nested subgraph structures. - Compatibility with ONNX opset versions beyond what the fact sheet documents. ## Package facts - License: MIT License (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 83.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags onnx model attribute modifier, rewrite onnx operator parameters, onnx constant editor, modify onnx graph attributes, onnx op parameter tuning, onnx model parameter adjustment, simple onnx editing tool, onnx-tools, model-editing, ml-ops [View on SkillFed](https://skillfed.io/packages/sam4onnx) · [View on PyPI](https://pypi.org/project/sam4onnx/)