rwightman / efficientdet-pytorch

A PyTorch impl of EfficientDet faithful to the original Google impl w/ ported weights
Apache License 2.0
1.58k stars 293 forks source link

jit-traced models won't work with different inputs when recompute_scale_factor is True in Interpolate2d #169

Closed NicolaiHarich closed 3 years ago

NicolaiHarich commented 3 years ago

Hi, after tracing the model with "torch.jit.trace" and an example input I realized that the model won't work when you change the input orientation (e.g. from portrait to landscape). I believe the reason for this behaviour is that Interpolate2d uses recompute_scale_factor=True.

Is there any reason why you have to enable "recompute_scale_factor"? If not, can we set the recompute_scale_factor to False in the Interpolate2d layer? https://github.com/rwightman/efficientdet-pytorch/blob/23ae71ab48f4b464b7e8e4458b6b181f4c9d1c52/effdet/efficientdet.py#L133

rwightman commented 3 years ago

@NicolaiHarich I didn't realize there was an interaction btw that param and tracing... I'll take a look and see if it's safe to remove (doesn't impact results).