I’m by no means an expert, but I think you can use the dynamic_axes optional argument to onnx.export
In the tutorial here 45 (about a quarter of the way down) the example uses the dynamic_axes argument to have a dynamic batch size:
                  dynamic_axes={'input' : {0 : 'batch_size'},    # variable lenght axes
                                'output' : {0 : 'batch_size'}})

I assume that can also be done for the other axes, but I haven’t tried it - my use case has images which are guaranteed to be the same size, so I don’t need it.
I have seen some discussion that would suggest this is not the case though, so maybe someone with more experience can weigh in?