[Bugfix] Re-land MiniMax M3 default video processor (#50305)

Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
Signed-off-by: Isotr0py <Isotr0py@outlook.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Taneem Ibrahim
2026-07-31 07:46:18 +00:00
committed by GitHub
co-authored by OpenAI Codex Isotr0py
parent 10e6b40015
commit f727951d3f
3 changed files with 42 additions and 12 deletions
+34 -11
View File
@@ -3,8 +3,9 @@
import math
from collections.abc import Mapping, Sequence
from typing import cast
from typing import Any, Literal, cast
import numpy.typing as npt
import torch
from transformers import BatchFeature
from transformers.video_utils import VideoMetadata
@@ -469,10 +470,39 @@ class MiniMaxM3VLMultiModalProcessor(
]
# TODO(Isotr0py): Tie with MinimaxVideoProcessor
# after https://github.com/vllm-project/vllm/pull/44126
@VIDEO_LOADER_REGISTRY.register("minimax_m3_vl")
@VIDEO_LOADER_REGISTRY.register(
name="minimax_m3_vl",
video_processor="MiniMaxM3VLVideoProcessor",
)
class MiniMaxM3VideoBackend(VideoBackend):
@classmethod
def load_bytes(
cls,
data: bytes,
num_frames: int = -1,
fps: int = 1,
max_duration: int = 300,
frame_recovery: bool = False,
*,
backend: Literal[
"opencv",
"pyav",
"torchcodec",
"pynvvideocodec",
"deepstream",
] = "opencv",
**kwargs,
) -> tuple[npt.NDArray, dict[str, Any]]:
return super().load_bytes(
data,
num_frames=num_frames,
fps=fps,
max_duration=max_duration,
frame_recovery=frame_recovery,
backend=backend,
**kwargs,
)
@classmethod
def compute_frames_index_to_sample(
cls,
@@ -483,7 +513,6 @@ class MiniMaxM3VideoBackend(VideoBackend):
total_frames = source.total_frames_num
video_fps = source.original_fps
fps = target.fps
if total_frames <= 0 or video_fps <= 0 or fps <= 0:
return [0] if total_frames > 0 else []
@@ -503,12 +532,6 @@ class MiniMaxM3VideoBackend(VideoBackend):
break
indices.append(target_frame)
prev_kept_ts = target_frame / video_fps
last_frame_idx = total_frames - 1
last_ts = last_frame_idx / video_fps
if indices and indices[-1] != last_frame_idx and last_ts - prev_kept_ts > eps:
indices.append(last_frame_idx)
if not indices:
indices = [0]
return indices