ENOT-AutoDL / onnx2torch

Convert ONNX models to PyTorch.
Apache License 2.0
610 stars 71 forks source link

Is there a way to remove onnx dependency? #179

Closed Nikita-Sherstnev closed 1 year ago

Nikita-Sherstnev commented 1 year ago

Hello there! Great job on the library. When I try to load the model with Torch, it requires having both ONNX and this library installed as dependencies. Is there a way to eliminate this dependencies completely, perhaps by manually rewriting the network?

senysenyseny16 commented 1 year ago

Hi @Nikita-Sherstnev,

It is theoretically possible to separate the PyTorch and ONNX parts, but in the current design the parts are tightly coupled:

When the model is already converted to PyTorch, ONNX dependency is not required to for inference or train, but in the current implementation, the imports of PyTorch and ONNX are in the same file -- removing ONNX will result in an ImportError exception.

RocketHog55 commented 9 months ago

I just tried working around this by installing onnx2torch and onnx using pip's --no-dependencies switch: pip install onnx2torch onnx --no-dependencies and my model loaded successfully 🍡.