likyoo / open-cd

A Change Detection Repo Standing on the Shoulders of Giants
https://arxiv.org/abs/2407.15317
Apache License 2.0
552 stars 77 forks source link

ONNX export.py #103

Open OhSungChoo opened 5 months ago

OhSungChoo commented 5 months ago

torch.onnx.errors.SymbolicValueError: Unsupported: ONNX export of instance_norm for unknown channel size. [Caused by the value 'input.411 defined in (%input.411 : Float(, , , , strides=[3276800, 25600, 160, 1], requires_grad=0, device=cpu) = onnx::Conv[dilations=[1, 1], group=128, kernel_shape=[5, 5], pads=[2, 2, 2, 2], strides=[1, 1]](%input.407, %decode_head.neck_layer.flow_make.0.weight, %decode_head.neck_layer.flow_make.0.bias), scope: opencd.models.change_detectors.dual_input_encoder_decoder.DIEncoderDecoder::/opencd.models.decode_heads.changer.FDAF::neck_layer/mmengine.model.base_module.Sequential::flow_make/torch.nn.modules.conv.Conv2d::flow_make.0 # /data/ohsung/anaconda3/envs/changer/lib/python3.8/site-packages/torch/nn/modules/conv.py:456:0 )' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Conv'.]


python tools/export.py -c configs/changer/changer_ex_r18_512x512_40k_levircd.py \ -m /data/ohsung/repos/open-cd/321_S/best_mIoU_iter_800.pth \ -i "1,3,640,640" "1,3,640,640" \ -mn changer.onnx


I tried to run the export.py but the error came out as the abvoe one

i can't figure it out what the problem is

Can I get a help?

GreatV commented 3 months ago

The error you're encountering is related to the ONNX export of the instance_norm operation with an unknown channel size in the Conv layer of your model. This is a known limitation in the current state of ONNX export for certain PyTorch operations.

Clichong commented 2 months ago

torch.onnx.errors.SymbolicValueError: Unsupported: ONNX export of instance_norm for unknown channel size. [Caused by the value 'input.411 defined in (%input.411 : Float(, , , , strides=[3276800, 25600, 160, 1], requires_grad=0, device=cpu) = onnx::Conv[dilations=[1, 1], group=128, kernel_shape=[5, 5], pads=[2, 2, 2, 2], strides=[1, 1]](%input.407, %decode_head.neck_layer.flow_make.0.weight, %decode_head.neck_layer.flow_make.0.bias), scope: opencd.models.change_detectors.dual_input_encoder_decoder.DIEncoderDecoder::/opencd.models.decode_heads.changer.FDAF::neck_layer/mmengine.model.base_module.Sequential::flow_make/torch.nn.modules.conv.Conv2d::flow_make.0 # /data/ohsung/anaconda3/envs/changer/lib/python3.8/site-packages/torch/nn/modules/conv.py:456:0 )' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Conv'.]

python tools/export.py -c configs/changer/changer_ex_r18_512x512_40k_levircd.py -m /data/ohsung/repos/open-cd/321_S/best_mIoU_iter_800.pth -i "1,3,640,640" "1,3,640,640" -mn changer.onnx

I tried to run the export.py but the error came out as the abvoe one

i can't figure it out what the problem is

Can I get a help?

您好, 遇到了一样的问题,请问后面如何解决呢?