[Bugfix] MiniCPM-V-4.6 video inference crash: placeholder count mismatches visual embedding count (#44509)

Signed-off-by: tc-mb <tianchi_cai@icloud.com>
This commit is contained in:
tc-mb
2026-06-04 08:22:30 -07:00
committed by GitHub
parent b21443e23c
commit 3dbb4e0ace
2 changed files with 60 additions and 2 deletions
+8 -1
View File
@@ -378,7 +378,14 @@ class VideoProcessorItems(ProcessorBatchItems[HfVideoItem | None]):
if isinstance(image, PILImage.Image):
return ImageSize(*image.size)
if isinstance(image, (np.ndarray, torch.Tensor)):
_, h, w = image.shape
if image.ndim == 3 and image.shape[-1] in (1, 3, 4):
# HWC format (e.g. from np.array(PIL.Image) via
# _get_video_with_metadata). PIL images are always
# channels-last.
h, w = image.shape[0], image.shape[1]
else:
# CHW format (standard PyTorch / numpy convention).
_, h, w = image.shape
return ImageSize(w, h)
assert_never(image)