vision icon indicating copy to clipboard operation
vision copied to clipboard

`NEAREST_EXACT` and `BICUBIC` work against the doc of `RandAugment()`

Open hyperkai opened this issue 8 months ago • 2 comments

🐛 Describe the bug

The doc of RandAugment() says that only NEAREST and BILINEAR are supported:

Parameters: ...

  • interpolation (InterpolationMode, optional) – ... If input is Tensor, only InterpolationMode.NEAREST, InterpolationMode.BILINEAR are supported.

But NEAREST_EXACT and BICUBIC work against the doc as shown below:

from torchvision.datasets import OxfordIIITPet
from torchvision.transforms.v2 import RandAugment, PILToTensor

origin_data = OxfordIIITPet(
    root="data"
)

def show_raimagetensor(im, ip=None):
    ra = RandAugment(interpolation=ip)
    ptt = PILToTensor()
    print(ptt(ra(im))[0][200])

show_raimagetensor(im=origin_data[0][0], ip=InterpolationMode.NEAREST_EXACT)
# tensor([ 29,  29,  29,  29,  28,  29,  30,  30,  30,  30,
#          30,  31,  27,  28,  28,  28,  29,  28,  28,  29,
#          29,  26,  28,  29,  29, ...,  29,  26,  26], dtype=torch.uint8)

show_raimagetensor(im=origin_data[0][0], ip=InterpolationMode.BICUBIC)
# tensor([249, 248, 247, 245, 242, 241, 241, 237, 235, 239,
#         237, 239, 238, 229, 231, 229, 234, 238, 240, 246,
#         248, 244, 246, 245, 246, ..., 250, 247, 247], dtype=torch.uint8)

Versions

import torchvision

torchvision.__version__ # '0.20.1'

hyperkai avatar May 16 '25 13:05 hyperkai

Hey @hyperkai, thank you for opening this issue. After reviewing the details, I suggest we consolidate the discussion with #9065, as it appears to be closely related.

AntoineSimoulin avatar May 21 '25 13:05 AntoineSimoulin

Feel free to submit a PR to clarify the docs @hyperkai .

NicolasHug avatar May 29 '25 12:05 NicolasHug