-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
We added support for decoding 16 bit pngs in #4657.
Pytorch doesn't support uint16 dtype, so we have to return a int32 tenor instead. However as @nairbv pointed out, this can lead to unexpected behaviour for the convert_image_dtype(), because this function relies on the max value of a given dtype to carry the conversions.
While the actual max value of a 16 bits image is 2**16 - 1, convert_image_dtype() will assume that it's (2**31 - 1) because the image is in a int32 tensor. This leads to e.g. a tensor full of zeros when converting to uint8.
Potential solutions are:
- native support for uint16 in pytorch
- add a new
input_range=Noneparameter toconvert_image_dtype()(not a fan of that)
For now, I'll just make this a private API (e.g. _decode_16bits_png() or something). It will still allow to continue the work on RAFT, which was the main reason I needed 16bits decoding in the first place.