Skip to content

Conversation

maxfrei750
Copy link
Contributor

@maxfrei750 maxfrei750 commented Jan 11, 2021

torchvision.models.detection.transforms._resize_image_and_masks raises the following warning, when being run with torch>=1.6.0:

UserWarning: The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and now uses scale_factor directly, instead of relying on the computed output size. If you wish to restore the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details.

This was already mentioned in #2154, but apparently not fixed yet.

This PR fixes the warning by restoring the original behavior.

EDIT: I think, originally, @java-abhinav07 wanted to create a PR, so he might have some insights on whether the fix is good.

UserWarning: The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and now uses scale_factor directly, instead of relying on the computed output size. If you wish to restore the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details.
@datumbox datumbox requested review from datumbox and fmassa and removed request for datumbox January 11, 2021 13:09
Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxfrei750 Thanks for the PR.

If this is to be addressed like this we will probably need to also aligning the onnx method:

mask = F.interpolate(mask[:, None].float(), scale_factor=scale_factor)[:, 0].byte()

@fmassa Could you also have a look to confirm if we want to maintain the old behaviour here?

@fmassa
Copy link
Member

fmassa commented Jan 20, 2021

Thanks for the PR!

@datumbox I would say that this PR keeps the old behavior (but without the warning), so this is good.
If we wanted to switch in the future to the new default behavior (recompute_scale_factor=False), we would need to perform a validation of the results to see if it affects the results a bit (I don't think it should affect them in a significant manner, but would still be good to validate)

@maxfrei750 can you address the other comment from @datumbox so that we can get this PR merged?

@maxfrei750
Copy link
Contributor Author

@fmassa Thanks for the review.

I just made the requested change.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fmassa fmassa merged commit a2908d8 into pytorch:master Jan 20, 2021
facebook-github-bot pushed a commit that referenced this pull request Feb 1, 2021
…e_and_masks. (#3237)

Summary:
* Fixed warning.

UserWarning: The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and now uses scale_factor directly, instead of relying on the computed output size. If you wish to restore the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details.

* Aligned _resize_image_and_masks_onnx.

Reviewed By: datumbox

Differential Revision: D26156361

fbshipit-source-id: b5ff04482f2c371843a867a735b69ca501cb23ce

Co-authored-by: Francisco Massa <fvsmassa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants