System Info
- transformers main (commit 8c62d6f)
- Windows 11, Python 3.13
- numpy
Who can help?
@molbap @guarin
Reproduction
Was processing some RGBA video frames as numpy arrays and noticed the output shape is wrong after convert_to_rgb. Here's a minimal example:
import numpy as np
from transformers.video_utils import convert_to_rgb
video = np.array(
[
[[[255, 0, 0, 128]]],
[[[0, 255, 0, 64]]],
],
dtype=np.uint8,
)
rgb_video = convert_to_rgb(video, input_data_format="channels_last")
print(rgb_video.shape) # prints (2, 2, 1, 1) — should be (2, 3, 1, 1)
Looks like the blending line in convert_to_rgb (video_utils.py:789) uses video[..., 3, :, :] as the foreground instead of video[..., :3, :, :], so the alpha channel ends up being used as the RGB data. This causes both the wrong channel count and incorrect pixel values.
Expected behavior
Output shape should be (2, 3, 1, 1) — 3 RGB channels after blending the alpha with white background. The alpha channel should be used for blending only, not as the foreground color.
System Info
Who can help?
@molbap @guarin
Reproduction
Was processing some RGBA video frames as numpy arrays and noticed the output shape is wrong after
convert_to_rgb. Here's a minimal example:Looks like the blending line in
convert_to_rgb(video_utils.py:789) usesvideo[..., 3, :, :]as the foreground instead ofvideo[..., :3, :, :], so the alpha channel ends up being used as the RGB data. This causes both the wrong channel count and incorrect pixel values.Expected behavior
Output shape should be
(2, 3, 1, 1)— 3 RGB channels after blending the alpha with white background. The alpha channel should be used for blending only, not as the foreground color.