Unverified Commit a2908d88 authored by Max Frei's avatar Max Frei Committed by GitHub
Browse files

Fixed warning in torchvision.models.detection.transforms._resize_image_and_masks. (#3237)



* 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.
Co-authored-by: default avatarFrancisco Massa <fvsmassa@gmail.com>
parent 146dd855
......@@ -27,7 +27,7 @@ def _resize_image_and_masks_onnx(image, self_min_size, self_max_size, target):
if "masks" in target:
mask = target["masks"]
mask = F.interpolate(mask[:, None].float(), scale_factor=scale_factor)[:, 0].byte()
mask = F.interpolate(mask[:, None].float(), scale_factor=scale_factor, recompute_scale_factor=True)[:, 0].byte()
target["masks"] = mask
return image, target
......@@ -49,7 +49,7 @@ def _resize_image_and_masks(image, self_min_size, self_max_size, target):
if "masks" in target:
mask = target["masks"]
mask = F.interpolate(mask[:, None].float(), scale_factor=scale_factor)[:, 0].byte()
mask = F.interpolate(mask[:, None].float(), scale_factor=scale_factor, recompute_scale_factor=True)[:, 0].byte()
target["masks"] = mask
return image, target
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment