KushajveerSingh / resize_network_cv

PyTorch implementation of the paper "Learning to Resize Images for Computer Vision Tasks" on Imagenette and Imagewoof datasets
Apache License 2.0
57 stars 11 forks source link

Suggestion: Handle Input Image of Any Aspect Ratio #3

Open bilzard opened 3 years ago

bilzard commented 3 years ago

The original paper says:

... the proposed architecture allows for resizing an image to any target size and aspect ratio.

So the Resizer should handle input image with any aspect ratio. In spite of that, the Resizer implementation (interpolation) seems to assume the input image is square (or, only handle uniform-scale resize: e.g. (512, 256) -> (256, 128)).

The current implementation interpolates by specifying scale_factor, though I think it's more useful to specify the output image size and calculate scale factor automatically.

The reference code:

# current implementation
self.interpolate = partial(F.interpolate,
                           scale_factor=self.scale_factor,
                           mode=self.interpolate_mode,
                           align_corners=False,
                           recompute_scale_factor=False)
# suggestion
self.interpolate = partial(F.interpolate,
                           size=output_size,
                           mode=self.interpolate_mode,
                           align_corners=False)

c.f. https://github.com/KushajveerSingh/resize_network_cv/blob/main/src/models/resizer.py#L56-L60

KushajveerSingh commented 3 years ago

Thank you for the suggestion. I will try to complete this in the next few days.