Description
On the surface F.pad
for PIL images seems to support str arguments for fill
:
vision/torchvision/transforms/functional_pil.py
Lines 157 to 158 in 053e7eb
Internally though, it calls _parse_fill
vision/torchvision/transforms/functional_pil.py
Lines 304 to 308 in 053e7eb
which in most cases relies on fill being numeric. Thus, actually passing a string doesn't work although PIL supports it.
>>> image = PIL.Image.fromarray(torch.randint(0, 256, (256, 256, 3), dtype=torch.uint8).numpy())
>>> F.pad(image, 128, fill="black")
ValueError: invalid literal for int() with base 10: 'black'
>>> PIL.ImageOps.expand(image, border=128, fill="black")
<PIL.Image.Image image mode=RGB size=512x512 at 0x7FA4DD37FBD0>
This traces back to #2284 and specifically to
vision/torchvision/transforms/functional.py
Lines 334 to 337 in 37a0d8d
which will makes no sense for fill: str
.
Given that #2284 was included from 0.7.0
upwards and we haven't gotten any report yet, my guess is that the functionality is not really used. Since we want to deprecate fill: str
anyway (#5621 (comment)), I would opt to simply remove all mentions of it. Thoughts?