-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Labels
Description
🐛 Describe the bug
The augment FixedSizeCrop
in the detection recipe is filled with mean=(123.0, 117.0, 104.0)
but when we call the padding function:
vision/references/detection/transforms.py
Line 356 in 2921174
img = F.pad(img, padding, self.fill, self.padding_mode) |
we should use
int
not float
as it produces the following error:
~/anaconda3/envs/pt1.11-tv0.12-cu10.2/lib/python3.7/site-packages/torchvision/transforms/functional.py in pad(img, padding, fill, padding_mode)
483 _log_api_usage_once(pad)
484 if not isinstance(img, torch.Tensor):
--> 485 return F_pil.pad(img, padding=padding, fill=fill, padding_mode=padding_mode)
486
487 return F_t.pad(img, padding=padding, fill=fill, padding_mode=padding_mode)
~/anaconda3/envs/pt1.11-tv0.12-cu10.2/lib/python3.7/site-packages/torchvision/transforms/functional_pil.py in pad(img, padding, fill, padding_mode)
166 return image
167
--> 168 return ImageOps.expand(img, border=padding, **opts)
169 else:
170 if isinstance(padding, int):
~/anaconda3/envs/pt1.11-tv0.12-cu10.2/lib/python3.7/site-packages/PIL/ImageOps.py in expand(image, border, fill)
402 else:
403 palette = None
--> 404 out = Image.new(image.mode, (width, height), color)
405 if palette:
406 out.putpalette(palette.palette)
~/anaconda3/envs/pt1.11-tv0.12-cu10.2/lib/python3.7/site-packages/PIL/Image.py in new(mode, size, color)
2668 im.palette = ImagePalette.ImagePalette()
2669 color = im.palette.getcolor(color)
-> 2670 return im._new(core.fill(mode, size, color))
2671
2672
TypeError: integer argument expected, got float
We can either cast the tuple
of float
to a tuple of int
with
self.fill = tuple(map(int, fill))
in the __init__
or change the value in the presets
script.
Versions
[pip3] numpy==1.21.5
[pip3] torch==1.11.0
[pip3] torchvision==0.12.0
[conda] blas 1.0 mkl
[conda] cudatoolkit 10.2.89 hfd86e86_1
[conda] ffmpeg 4.3 hf484d3e_0 pytorch
[conda] mkl 2021.4.0 h06a4308_640
[conda] mkl-service 2.4.0 py37h7f8727e_0
[conda] mkl_fft 1.3.1 py37hd3c417c_0
[conda] mkl_random 1.2.2 py37h51133e4_0
[conda] numpy 1.21.5 py37he7a7128_1
[conda] numpy-base 1.21.5 py37hf524024_1
[conda] pytorch 1.11.0 py3.7_cuda10.2_cudnn7.6.5_0 pytorch
[conda] pytorch-mutex 1.0 cuda pytorch
[conda] torchvision 0.12.0 py37_cu102 pytorch