PINTO0309 / PINTO_model_zoo

A repository for storing models that have been inter-converted between various frameworks. Supported frameworks are TensorFlow, PyTorch, ONNX, OpenVINO, TFJS, TFTRT, TensorFlowLite (Float32/16/INT8), EdgeTPU, CoreML.
https://qiita.com/PINTO
MIT License
3.49k stars 566 forks source link

Documentation support for Crestereo Pytorch model conversion to onnx model #335

Closed ashank-art closed 1 year ago

ashank-art commented 1 year ago

Issue Type

Support

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

PyTorch, ONNX

Model name and Weights/Checkpoints URL

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/284_CREStereo

Description

Hi, Thank you for your great work.

Can you guide me through the procedure for converting CreStereo PyTorch model to Onnx model.? As per the documents, it says You need to convert the model twice, once without the init_flow and once with the init_flow. So the commented out part in your script are not options, but two separate runs. Then use the merging tool PINTO0309 developed to merge the two parts into one. Or, just use them separately in sequence.

But in the second step while using onnx_merge.py ,

i am facing the issue attached in the below error log

Relevant Log Output

Traceback (most recent call last):
  File "onnx_merge.py", line 17, in <module>
    combined_model = onnx.compose.merge_models(
  File "/home/virtual_environments/cre_pytorch/lib/python3.8/site-packages/onnx/compose.py", line 363, in merge_models
    graph = merge_graphs(
  File "/home/virtual_environments/cre_pytorch/lib/python3.8/site-packages/onnx/compose.py", line 187, in merge_graphs
    raise ValueError(f"Input {g2_in_name} is not present in g2")
ValueError: Input next_flow_init is not present in g2

URL or source code for simple inference testing code

No response

PINTO0309 commented 1 year ago

No special knowledge is required.

https://github.com/PINTO0309/PINTO_model_zoo/blob/046e5f1627ab7f3aeb4a38ddde79699c1880670f/284_CREStereo/onnx_merge.py#L55-L58

Simply follow the process as described in the official ONNX documentation.

https://onnx.ai/onnx/api/compose.html