Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize functional transforms arguments #2479

Closed
vfdev-5 opened this issue Jul 16, 2020 · 2 comments
Closed

Harmonize functional transforms arguments #2479

vfdev-5 opened this issue Jul 16, 2020 · 2 comments

Comments

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Jul 16, 2020

🚀 Feature

Currently, we can observe a certain freedom in argument names and their meaning:

  1. Methods F.resize, F.resized_crop, F.perspective

def resize(img: Tensor, size: List[int], interpolation: int = Image.BILINEAR) -> Tensor:

def resized_crop(
img: Tensor, top: int, left: int, height: int, width: int, size: List[int], interpolation: int = Image.BILINEAR
) -> Tensor:

def perspective(img, startpoints, endpoints, interpolation=Image.BICUBIC, fill=None):

have

  • interpolation argument
  • fill argument
  1. Methods F.rotate, F.affine

def rotate(img, angle, resample=False, expand=False, center=None, fill=None):

def affine(
img: Tensor, angle: float, translate: List[int], scale: float, shear: List[float],
resample: int = 0, fillcolor: Optional[int] = None
) -> Tensor:

have

  • resample argument for interpolation (with a wrong default value as bool instead of int)
  • fill or fillcolor arguments for filling outside part of image
  1. Argument angle is interpreted differently between F.rotate, F.affine.
  • Affine: angle (float or int): rotation angle in degrees between -180 and 180, clockwise direction.
  • Rotate: angle (float or int): In degrees degrees counter clockwise order.

Idea is to harmonize the API:

  • choose a single name for interpolation and resample
  • choose a single name for fill and fillcolor
  • BC breaking change for angle ?

Maybe, there are other arguments to add to this list.

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Nov 2, 2020

Similar things with Transforms module and classes:

  • RandomRotation: fill/resample
  • RandomAffine: fillcolor/resample
  • RandomPerspective: fill/interpolation
  • RandomResizedCrop: interpolation
  • Pad: fill
  • RandomCrop: fill
  • Resize: interpolation
  1. fill is mainly used: 4 times in transforms and 3 times in functional vs fillcolor is used 2 times in transforms and functional (RandomAffine and F.affine) => we can decide to replace fillcolor by fill and set a warning about argument deprecation.

  2. interpolation is used 6 times in transforms/functional vs resample is used 4 times in transforms/functional => we can similarly decide to replace resample by interpolation and set a warning about argument deprecation.

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Sep 27, 2021

Close this issue as fixed by #2952 and #2904

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant