--- id: onnx2torch version: "1.5.15" license: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) license_treatment: permissive maintenance: aging --- # onnx2torch — ONNX to PyTorch converter License: permissive · Maintenance: aging · Downloads: 225.7K/mo ## What it is and what it does onnx2torch is a converter that transforms ONNX model files into native PyTorch modules. It accepts either a file path or a loaded ONNX model object and returns a PyTorch nn.Module that can be used directly for inference or training. The converter is designed to be extensible—you can register custom PyTorch layers for unsupported ONNX operations using a decorator pattern, and converted models can be exported back to ONNX using torch.onnx.export. The package supports a curated set of models including popular segmentation architectures (DeepLabV3+, UNet, HRNet), detection models (YOLOv3, YOLOv5, RetinaNet), classification networks (ResNet, MobileNet, EfficientNet, ViT), and transformers (Swin, GPT-J). However, it covers only a limited number of ONNX operations, so not all ONNX models will convert successfully. The maintainers explicitly encourage users to report unsupported models and operations. Use it for: - Convert a pre-trained ONNX model to PyTorch for fine-tuning or inference in a PyTorch-native pipeline. - Integrate ONNX-exported models from other frameworks into a PyTorch codebase. - Extend the converter with custom layers to support domain-specific ONNX operations not yet in the core library. - Validate ONNX model behavior by running inference in PyTorch and comparing outputs against ONNX Runtime. - Deploy ONNX models trained elsewhere as native PyTorch modules without maintaining separate inference code. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Converts ONNX models to PyTorch modules with a simple API, supporting a limited but growing set of operations and popular model architectures. Yes, if you need to convert ONNX models to PyTorch and your model uses supported operations. The package is stable and permissively licensed, with low install friction. However, verify that your specific ONNX model's operations are supported before committing to it—the converter does not support all ONNX operations, and maintenance has slowed. If your model is unsupported, you may need to implement custom converters or consider alternatives. ## Install pip install onnx2torch uv add onnx2torch poetry add onnx2torch ## Installing onnx2torch Before you install: Low install friction with a pure Python wheel. Maintenance is aging—last release was over a year ago, though the repository remains active and the project is marked Production/Stable. License in practice: Apache License 2.0 is permissive; you may use, modify, and distribute this package freely in commercial and private projects provided you include the license and attribute the original work. Quickstart: pip install onnx2torch import torch from onnx2torch import convert torch_model = convert("/path/to/model.onnx") output = torch_model(torch.randn(1, 3, 224, 224)) Requires torch and torchvision installed; conversion success depends on whether the ONNX model's operations are in the supported set. Verify before relying: - Whether all operations in your specific ONNX model are currently supported by this version. - Performance characteristics of converted models compared to native PyTorch implementations. - Compatibility with ONNX opset versions beyond those documented in the description. ## Package facts - License: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 225.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags onnx to pytorch conversion, convert onnx models to torch, onnx model converter, pytorch from onnx, onnx2torch converter, deep learning model format conversion, model-conversion, onnx, pytorch [View on SkillFed](https://skillfed.io/packages/onnx2torch) · [View on PyPI](https://pypi.org/project/onnx2torch/)