[diffusion][feature] Add LingBot-Video T2I and TI2V generation modes (#5311)
Signed-off-by: wtz2333 <2955110911@qq.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
11f633aa83
commit
36135ef09a
28 files changed
+2410
-98
No files matched your search
@@ -28,6 +28,7 @@ from vllm_omni.entrypoints.openai.api_server import router
|
||||
from vllm_omni.entrypoints.openai.protocol.videos import (
|
||||
VideoGenerationRequest,
|
||||
VideoGenerationStatus,
|
||||
VideoParams,
|
||||
VideoResponse,
|
||||
)
|
||||
from vllm_omni.entrypoints.openai.serving_video import OmniOpenAIServingVideo
|
||||
@@ -440,6 +441,75 @@ def test_i2v_video_generation_resizes_input_to_requested_dimensions(test_client,
|
||||
assert input_image.size == (96, 64)
|
||||
|
||||
|
||||
def test_i2v_extra_params_dimensions_preserve_input_image_geometry(test_client, mocker: MockerFixture):
|
||||
image_bytes = _make_test_image_bytes((48, 48))
|
||||
mocker.patch(
|
||||
"vllm_omni.entrypoints.openai.serving_video._encode_video_bytes",
|
||||
return_value=b"fake-video",
|
||||
)
|
||||
response = test_client.post(
|
||||
"/v1/videos",
|
||||
data={
|
||||
"prompt": "A bear playing with yarn.",
|
||||
"extra_params": json.dumps({"width": 96, "height": 64}),
|
||||
},
|
||||
files={"input_reference": ("input.png", image_bytes, "image/png")},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
video_id = response.json()["id"]
|
||||
_wait_for_status(test_client, video_id, VideoGenerationStatus.COMPLETED.value)
|
||||
|
||||
engine = test_client.app.state.openai_serving_video._engine_client
|
||||
input_image = engine.captured_prompt["multi_modal_data"]["image"]
|
||||
assert isinstance(input_image, Image.Image)
|
||||
assert input_image.size == (48, 48)
|
||||
sampling_params = engine.captured_sampling_params_list[0]
|
||||
assert sampling_params.extra_args["width"] == 96
|
||||
assert sampling_params.extra_args["height"] == 64
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("generation_request", "expected_num_frames", "expected_duration"),
|
||||
[
|
||||
(
|
||||
VideoGenerationRequest(prompt="top-level frames", seconds="5", num_frames=9),
|
||||
9,
|
||||
5.0,
|
||||
),
|
||||
(
|
||||
VideoGenerationRequest(prompt="nested frames", video_params=VideoParams(num_frames=9)),
|
||||
9,
|
||||
None,
|
||||
),
|
||||
(
|
||||
VideoGenerationRequest(prompt="seconds only", seconds="5"),
|
||||
120,
|
||||
5.0,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_video_generation_bridges_request_fields(generation_request, expected_num_frames, expected_duration):
|
||||
engine = FakeAsyncOmni()
|
||||
handler = OmniOpenAIServingVideo.for_diffusion(
|
||||
diffusion_engine=engine,
|
||||
model_name="Wan-AI/Wan2.2-T2V-A14B-Diffusers",
|
||||
)
|
||||
|
||||
asyncio.run(handler._run_and_extract(generation_request, "field-bridge"))
|
||||
|
||||
sampling = engine.captured_sampling_params_list[0]
|
||||
# Top-level ``seconds`` bridges into extra_args["duration"]; num_frames is
|
||||
# passed through (or derived as seconds x fps when omitted). No private
|
||||
# provenance channel is injected.
|
||||
assert "_vllm_request_context" not in sampling.extra_args
|
||||
assert sampling.num_frames == expected_num_frames
|
||||
if expected_duration is None:
|
||||
assert "duration" not in sampling.extra_args
|
||||
else:
|
||||
assert sampling.extra_args["duration"] == expected_duration
|
||||
|
||||
|
||||
def test_i2v_video_generation_with_image_reference_form(test_client, mocker: MockerFixture):
|
||||
mocker.patch(
|
||||
"vllm_omni.entrypoints.openai.serving_video._encode_video_bytes",
|
||||
|
||||
Reference in new issue
Block a user