Possible alpha-channel dimension typo in loadCam: shape[1] should be shape[0]
mentioned code in this repo: https://github.com/fastgs/FastGS/blob/main/utils/camera_utils.py#L46
Description:
In utils/camera_utils.py, loadCam() checks whether the resized image has four channels using:
if resized_image_rgb.shape[1] == 4:
loaded_mask = resized_image_rgb[3:4, ...]
However, PILtoTorch() returns a tensor in C x H x W format after calling permute(2, 0, 1). Therefore:
shape[0]is the channel countshape[1]is the image heightshape[2]is the image width
For a normal RGBA image, such as an 8 x 6 image, PILtoTorch() returns a tensor with shape (4, 6, 8). The current condition checks whether the image height is 4, so the alpha channel is not loaded.
This also causes an RGB image whose height happens to be 4 pixels to produce an empty mask with shape (0, 4, W).
Expected code:
if resized_image_rgb.shape[0] == 4:
loaded_mask = resized_image_rgb[3:4, ...]
Observed behavior:
RGBA image(.png), size 8 x 6:
tensor shape: (4, 6, 8)
loaded mask: None
RGB image(.jpg), size 8 x 4:
tensor shape: (3, 4, 8)
loaded mask shape: (0, 4, 8)
Expected behavior:
RGBA images should produce an alpha mask with shape (1, H, W), while RGB images should leave loaded_mask as None.