Unverified Commit 2780c889 authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

pil_to_tensor accimage backend return uint8 (#3109)

accimage always stores images as uint8, so let's be compatible with the internal representation. Tests were failing without this as it would return a float32 image normalized between 0-1
parent dab47572
......@@ -155,7 +155,8 @@ def pil_to_tensor(pic):
raise TypeError('pic should be PIL Image. Got {}'.format(type(pic)))
if accimage is not None and isinstance(pic, accimage.Image):
nppic = np.zeros([pic.channels, pic.height, pic.width], dtype=np.float32)
# accimage format is always uint8 internally, so always return uint8 here
nppic = np.zeros([pic.channels, pic.height, pic.width], dtype=np.uint8)
pic.copyto(nppic)
return torch.as_tensor(nppic)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment