This is often the case with medical (MRI) data.
Required changes would be in ToTensor probably something like:
# PIL image mode: 1, L, P, I, F, RGB, YCbCr, RGBA, CMYK
if pic.mode == 'YCbCr':
nchannel = 3
else:
nchannel = len(pic.mode)
# handle PIL Image
buf = pic.tobytes()
if len(buf) > pic.width * pic.height * nchannel:
img = torch.LongTensor(torch.LongStorage.from_buffer(buf))
else:
img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes()))
img = img.view(pic.size[1], pic.size[0], nchannel)
as well as in ToPILImage (just remove normalization to [0, 255] here?).
However I can't assess possible side effects. int16 support may be not very good in pillow (e.g. plt.imshow(Image.fromarray(int16_np_array)) does not work) also there may be other transforms which depend on [0, 255] byte range.
This is often the case with medical (MRI) data.
Required changes would be in ToTensor probably something like:
as well as in ToPILImage (just remove normalization to [0, 255] here?).
However I can't assess possible side effects.
int16support may be not very good in pillow (e.g.plt.imshow(Image.fromarray(int16_np_array))does not work) also there may be other transforms which depend on [0, 255] byte range.