_augmentation_space gives invalid range to Solarize threshold

The threshold argument of the Solarize transform can’t accept values above 255 when the image is a uint8. AutoAugment, RandAugmentcan, and TrivialAugmentWide produce augmentation spaces that go up to 256. This will give an error like:

File “/python3.9/site-packages/torchvision/transforms/autoaugment.py”, line 397, in forward
return _apply_op(img, op_name, magnitude, interpolation=self.interpolation, fill=fill)
File “/python3.9/site-packages/torchvision/transforms/autoaugment.py”, line 40, in _apply_op
img = F.solarize(img, magnitude)
File “/python3.9/site-packages/torchvision/transforms/functional.py”, line 1320, in solarize
return F_t.solarize(img, threshold)
File “/python3.9/site-packages/torchvision/transforms/functional_tensor.py”, line 874, in solarize
return torch.where(img >= threshold, inverted_img, img)
RuntimeError: value cannot be converted to type uint8_t without overflow: 256

Please correct the code in the _augmentation_space function in the autoaugment.py file:
wrong: “Solarize”: (torch.linspace(256.0, 0.0, num_bins), False),
right: “Solarize”: (torch.linspace(255.0, 0.0, num_bins), False),

This issue seems to be already fixed in this PR so you might want to update torchvision to the latest nightly or build from the current main branch.