SwinTransformer / Swin-Transformer-Object-Detection

This is an official implementation for "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" on Object Detection and Instance Segmentation.
https://arxiv.org/abs/2103.14030
Apache License 2.0
1.81k stars 381 forks source link

ONNX, onnx, #223

Open yyyyyxie opened 5 months ago

yyyyyxie commented 5 months ago

It seems that I can only export ONNX with a fixed input size. I hope to set the width and height as dynamic axes. However, after setting, the exported ONNX can still only use the original width and height as the unique input shape. image

yyyyyxie commented 5 months ago

If I use inputs of different sizes, it will throw an error similar to the one shown in the image. I've spent a lot of time and it seems that I haven't solved this problem.

Code: dynamic = {'inputs': {2: 'h', 3: 'w'}, 'outputs': {2: 'h', 3: 'w'}} torch.onnx.export(model, (img,), output_path, verbose=False, opset_version=17, input_names=['inputs'], output_names=['outputs'], dynamic_axes=dynamic)