-
Notifications
You must be signed in to change notification settings - Fork 7k
updated transforms.ToPILImage, see #105 #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I want to note that the way I handle single channel images with precision > 8-bit breaks from tradition to scale tensors to [0, 1] and images to [0, 255]. |
torchvision/transforms.py
Outdated
return img.float().div(255) | ||
# handle PIL Image | ||
if pic.mode == 'I': | ||
img = torch.from_numpy(np.array(pic, np.int32)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
I agree with you wrt keeping the original types and range of the image. |
👍 for the idea with the constructor. I you would use |
Yeah, maybe let the normalization factor by default to be 255, and maybe we only convert to float if the normalization factor is not Also, maybe a more descriptive name, such as |
01adcdf
to
85b166a
Compare
Sounds reasonable.
I don't think we need to pass the type around. In case of disabled normalization we can interfere type as implemented in the PR. If normalization should be applied we just expect |
looks pretty good, thank you! |
PR for #105. Changes should be backward compatible. Types are interfered from
PIL.Image.mode
when passing single channel images. See PIL modes hereHow does
ToPILImage
handle types?How does
ToTensor
handle types?