Closed
Description
Our UX for converting Dtype and scales is bad and error-prone in V2.
In #7743 we have a sample with an Image and a Mask. We need to:
- convert the image from uint8 to float and convert its scale from 0-255 to 0-1
- convert the mask from uint8 to int64, without converting its scale
The only way I found to do that right now is:
dtype= {
(datapoints.Image if backend == "datapoint" else torch.Tensor): None,
datapoints.Mask: torch.int64,
}
transforms += [T.ToDtype(dtype=dtype)]
transforms += [T.ConvertDtype(dtype=torch.float)]
We should at the very least:
- Clearly distinguish between
ConvertDtype
andToDtype
. It should be absolutely clear thatConvertDtype
also scales the values.ConvertDtypeAndScale()
is a decent candidate. Any new name is probably an improvement on the status quo. - Not error when
(datapoints.Image if backend == "datapoint" else torch.Tensor): None,
isn't passed. If I'm not converting a type, I shouldn't have to pass it as input.
Ideally I think we can get rid of ConvertDtype
and just add a scale
parameter to ToDtype()
:
scale=False
means no scaling happensscale=True
means all transformed inputs are scaled into the range specified by their dtypescale=Image
means only Image instances are scaledscale=(Image, Mask)
means only Images and Masks instances are scaled.
Metadata
Metadata
Assignees
Labels
No labels