[Feature] Align MiniMax H3 official input matrix (#5752)
Signed-off-by: david6666666 <530634352@qq.com>
This commit is contained in:
1 parent
6a604be610
commit
ae7bee0c43
21 files changed
+1887
-331
No files matched your search
@@ -15,6 +15,7 @@ from PIL import Image
|
||||
from vllm.engine.protocol import EngineClient
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from vllm_omni.diffusion.model_metadata import get_diffusion_model_metadata
|
||||
from vllm_omni.entrypoints.async_omni import AsyncOmni
|
||||
from vllm_omni.entrypoints.openai.protocol.videos import (
|
||||
VideoAction,
|
||||
@@ -42,7 +43,7 @@ logger = init_logger(__name__)
|
||||
class ReferenceImage:
|
||||
"""Reference class for tracking additional metadata if needed"""
|
||||
|
||||
data: Image.Image
|
||||
data: Image.Image | list[Image.Image]
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -57,7 +58,8 @@ class ReferenceVideo:
|
||||
class ReferenceAudio:
|
||||
"""Reference audio file path for speech-to-video generation."""
|
||||
|
||||
path: str
|
||||
path: str | list[str]
|
||||
cleanup_paths: tuple[str, ...] = ()
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -98,6 +100,21 @@ class OmniOpenAIServingVideo:
|
||||
if self._stage_configs is None and stage_configs is not None:
|
||||
self._stage_configs = stage_configs
|
||||
|
||||
@property
|
||||
def supports_mixed_reference_inputs(self) -> bool:
|
||||
"""Return whether the configured diffusion model accepts mixed refs."""
|
||||
get_od_config = getattr(self._engine_client, "get_diffusion_od_config", None)
|
||||
od_config = get_od_config() if callable(get_od_config) else getattr(self._engine_client, "od_config", None)
|
||||
if od_config is None:
|
||||
return False
|
||||
|
||||
capability = getattr(od_config, "supports_mixed_reference_inputs", None)
|
||||
if isinstance(capability, bool):
|
||||
return capability
|
||||
|
||||
model_class_name = getattr(od_config, "model_class_name", None)
|
||||
return get_diffusion_model_metadata(model_class_name).supports_mixed_reference_inputs
|
||||
|
||||
@classmethod
|
||||
def for_diffusion(
|
||||
cls,
|
||||
@@ -129,22 +146,26 @@ class OmniOpenAIServingVideo:
|
||||
|
||||
input_image = None if reference_image is None else reference_image.data
|
||||
input_video = None if reference_video is None else reference_video.data
|
||||
if input_image is not None and input_video is not None:
|
||||
if input_image is not None and input_video is not None and not self.supports_mixed_reference_inputs:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.BAD_REQUEST.value,
|
||||
detail="Provide either an image reference or a video reference, not both.",
|
||||
detail="This diffusion model does not support mixed image and video references.",
|
||||
)
|
||||
provided_fields = request.model_fields_set
|
||||
fps_provided = self._request_fps_provided(request)
|
||||
vp = request.resolve_video_params()
|
||||
if input_image is not None and vp.width is not None and vp.height is not None:
|
||||
target_size = (vp.width, vp.height)
|
||||
if input_image.size != target_size:
|
||||
input_image = input_image.resize(target_size, Image.Resampling.LANCZOS)
|
||||
image_items = input_image if isinstance(input_image, list) else [input_image]
|
||||
resized_images = [
|
||||
image.resize(target_size, Image.Resampling.LANCZOS) if image.size != target_size else image
|
||||
for image in image_items
|
||||
]
|
||||
input_image = resized_images if isinstance(input_image, list) else resized_images[0]
|
||||
multi_modal_data: dict[str, Any] = {}
|
||||
if input_image is not None:
|
||||
multi_modal_data["image"] = input_image
|
||||
elif input_video is not None:
|
||||
if input_video is not None:
|
||||
multi_modal_data["video"] = input_video
|
||||
if reference_audio is not None:
|
||||
multi_modal_data["audio"] = reference_audio.path
|
||||
@@ -155,6 +176,15 @@ class OmniOpenAIServingVideo:
|
||||
gen_params.height = vp.height
|
||||
if vp.num_frames is not None:
|
||||
gen_params.num_frames = vp.num_frames
|
||||
gen_params.num_outputs_per_prompt = request.num_outputs_per_prompt
|
||||
if request.seconds is not None:
|
||||
gen_params.extra_args.setdefault("duration", float(request.seconds))
|
||||
if request.aspect_ratio is not None:
|
||||
gen_params.extra_args["aspect_ratio"] = request.aspect_ratio
|
||||
if request.short_edge is not None:
|
||||
gen_params.extra_args["short_edge"] = request.short_edge
|
||||
if request.start_time_seconds is not None:
|
||||
gen_params.extra_args["start_time_seconds"] = request.start_time_seconds
|
||||
# Leave fps/frame_rate as None when the user did not provide fps.
|
||||
if fps_provided and vp.fps is not None:
|
||||
gen_params.fps = vp.fps
|
||||
|
||||
Reference in new issue
Block a user