Skip to content

Commit

Permalink
downgrade warnign for F.rotate with center and expand=True
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier committed Aug 30, 2023
1 parent a2189d6 commit 540dec5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion test/test_transforms_v2_refactored.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,6 @@ def test_transform_noop(self, make_input, device):
assert_equal(output, input)


@pytest.mark.filterwarnings("ignore:The provided center argument has no effect")
class TestRotate:
_EXHAUSTIVE_TYPE_AFFINE_KWARGS = dict(
# float, int
Expand Down
5 changes: 5 additions & 0 deletions torchvision/transforms/v2/_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ class RandomRotation(Transform):
Note that the expand flag assumes rotation around the center and no translation.
center (sequence, optional): Optional center of rotation, (x, y). Origin is the upper left corner.
Default is the center of the image.
..note::
In theory, ``center`` has no effect together with ``expand=True``. In practice however, this can lead to
off-by-one differences of the resulting image size compared to ``center=None``.
fill (number or tuple or dict, optional): Pixel fill value used when the ``padding_mode`` is constant.
Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively.
Fill value can be also a dictionary mapping data type to the fill value, e.g.
Expand Down
9 changes: 0 additions & 9 deletions torchvision/transforms/v2/functional/_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,6 @@ def rotate_image(

center_f = [0.0, 0.0]
if center is not None:
if expand:
# TODO: Do we actually want to warn, or just document this?
warnings.warn("The provided center argument has no effect on the result if expand is True")
# Center values should be in pixel coordinates but translated such that (0, 0) corresponds to image center.
center_f = [(c - s * 0.5) for c, s in zip(center, [width, height])]

Expand Down Expand Up @@ -1017,9 +1014,6 @@ def _rotate_image_pil(
) -> PIL.Image.Image:
interpolation = _check_interpolation(interpolation)

if center is not None and expand:
warnings.warn("The provided center argument has no effect on the result if expand is True")

return _FP.rotate(
image, angle, interpolation=pil_modes_mapping[interpolation], expand=expand, fill=fill, center=center
)
Expand All @@ -1033,9 +1027,6 @@ def rotate_bounding_boxes(
expand: bool = False,
center: Optional[List[float]] = None,
) -> Tuple[torch.Tensor, Tuple[int, int]]:
if center is not None and expand:
warnings.warn("The provided center argument has no effect on the result if expand is True")

return _affine_bounding_boxes_with_expand(
bounding_boxes,
format=format,
Expand Down

0 comments on commit 540dec5

Please sign in to comment.