Skip to content

Harmonize functional transforms arguments #2479

Closed
@vfdev-5

Description

@vfdev-5

🚀 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions