skillfed

scs4onnx

A very simple tool that compresses the overall size of the ONNX model by aggregating duplicate constant values as much as possible. Simple Constant value Shrink for ONNX.

scs4onnx v1.0.18 82.9K downloads/30d#14,122 on PyPI54
Permissive license MIT License Abandoned released

What it is and what it does

scs4onnx is a command-line and Python API tool for reducing ONNX model file sizes by finding and consolidating duplicate constant tensor values across the computation graph. It operates in two modes: 'shrink' mode keeps constants inside the model for maximum inference speed, while 'npy' mode extracts repeated constants to external .npy files for smaller model size at the cost of file-loading overhead. The tool can also optionally downcast Float64 to Float32 and INT64 to INT32 to further compress models, and supports forced extraction of specific operations or constants by name.

The package is a lightweight utility with no runtime dependencies beyond onnx itself. It was designed for processing large models where constant duplication inflates file size—the documentation shows real examples like reducing a 1.8GB model to 886.8MB or extracting weights to achieve 2.1MB model plus 884.7MB external data. However, the project has been abandoned since September 2022 and receives no maintenance, so it may not work reliably with ONNX models or toolchains released after that date.

Use it for:

  • Reduce deployment size of large computer vision models before shipping to edge devices or cloud inference endpoints.
  • Extract weights from extremely large models that hit Protocol Buffer size limits, splitting into smaller .onnx plus external .npy files.
  • Downcast high-precision models from Float64/INT64 to Float32/INT32 to save storage and improve inference speed.
  • Deduplicate constant tensors in models generated by converters or graph optimization tools that may have introduced redundant copies.
  • Prepare ONNX models for mobile or embedded deployment where model size impacts app download size and memory footprint.

Worth the install?

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

Compresses ONNX model files by deduplicating constant tensor values throughout the graph, with options to extract weights to external .npy files or downcast numeric types for further size reduction.

Yes, if you have a large ONNX model with duplicate constants and need to reduce its file size before deployment. Install friction is low and the tool is straightforward to use. However, the project is abandoned and has not been maintained since September 2022, so test thoroughly with your specific ONNX models and toolchain versions before relying on it in production. No known security vulnerabilities.

Install

scs4onnx on PyPI

pip

pip install scs4onnx

uv

uv add scs4onnx

poetry

poetry add scs4onnx

Installing scs4onnx

Before you install

Installs with no runtime dependencies and low friction. Project is abandoned as of September 2022 with no recent updates, so expect no bug fixes or maintenance going forward.

License in practice

MIT License permits free use, modification, and distribution with minimal restrictions, making it suitable for both open and proprietary projects.

Quickstart

pip install scs4onnx

from scs4onnx import shrinking

shrunk_graph, npy_paths = shrinking(
  input_onnx_file_path='input.onnx',
  output_onnx_file_path='output.onnx',
  mode='shrink'
)

Requires onnx package to be installed separately; Python >=3.6.

Verify before relying

  • Whether the tool works correctly with current ONNX opset versions released after September 2022
  • Compatibility with modern ONNX model architectures and recent PyTorch/TensorFlow exports
  • Performance impact of loading external .npy files in production inference pipelines

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 abandoned — 1,436 days since the last release
Last repo commit
First released
Downloads 82,855/month — #14,122 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: scs4onnx-1.0.18-py3-none-any.whl

Tags

onnx model compressionreduce onnx file sizededuplicate onnx constantsonnx weight extractionshrink neural network modelsonnx constant aggregationoptimize onnx graph size
model-optimizationonnx-toolscompression

More Artificial Intelligence packages