Error in apply_image function?
melisandeteng opened this issue · 2 comments
In the apply_image function here . , the expected input is HxWxC in order to use get_preprocess_shape to work.
However to_pil_image is called on this same input but it expects CxHxW. So it seems there is a permutation of axis missing in this function between the get_preprocess_shape and to_pil_image steps?
It's very odd code, but I think the assumption is that the input is from coming from opencv, which uses HxWxC ordering, and also BGR ordering on the channels which is accounted for when setting the image.
The to_pil_image
seems to be used specifically to match the resize function requirements, which wants a shape ending in HxW and a data type of a tensor or a PIL image. Given that the function returns an np.array, it probably would've been simpler to use cv2.resize
, but maybe they were trying to maintain consistency with some other implementation.
Thank you @heyoeyo, you answer made me realize I had an older version of torchvision (0.15.2) for which the to_pil_image function was not compatible...