onnx2torch
ONNX to PyTorch converter
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires torch and torchvision installed; conversion success depends on whether the ONNX model's operations are in the supported set.
- 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 · maintenance · safety
permissive license (permissive) — 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.
last release 2024-08-07 (737 days) · last repo commit 2025-10-14 · 739 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 225,660 downloads/mo, #9,216 on PyPI
Alternatives
Verify before relying
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))- 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.
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 on this page. Verify before relying on it.
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
onnx2torch on PyPI
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.
Requires torch and torchvision installed; conversion success depends on whether the ONNX model's operations are in the supported set.
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))
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 | permissive license permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagesnumpyonnxtorchtorchvision |
| Maintenance | Aging 737 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 225,660 / month, #9,216 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: PythonProgramming Language :: Python :: 3 :: Only |
Evidence: onnx2torch-1.5.15-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “onnx to pytorch conversion”
- onnx2torchConverts ONNX models to PyTorch modules with a simple API, supporting…
- onnx2tfConverts ONNX model files to LiteRT, TensorFlow, PyTorch,…
- onnxsimSimplifies ONNX neural network models by running constant folding,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also pnnx · tf2onnx · onnxmltools · onnx2tf · onnxsim · onnxconverter-common · onnx-graphsurgeon · litert-torch · torchprofile · hoptorch