[Enhancement]remove duplicate video preprocess in Wan2.2 pipeline (#2963)
Signed-off-by: bjf-frz <frz123db@gmail.com>
This commit is contained in:
1 parent
b001151e0d
commit
5f029ee4d5
5 files changed
-23
No files matched your search
@@ -44,7 +44,6 @@ def test_i2v_preprocess_requires_image_and_resizes_to_480p_aspect() -> None:
|
|||||||
assert result.sampling_params.height == 432
|
assert result.sampling_params.height == 432
|
||||||
assert result.sampling_params.width == 880
|
assert result.sampling_params.width == 880
|
||||||
assert prompt["multi_modal_data"]["image"].size == (880, 432)
|
assert prompt["multi_modal_data"]["image"].size == (880, 432)
|
||||||
assert prompt["additional_information"]["preprocessed_image"].shape[-2:] == (432, 880)
|
|
||||||
|
|
||||||
missing_image = SimpleNamespace(
|
missing_image = SimpleNamespace(
|
||||||
prompts=[{"prompt": "p", "multi_modal_data": {}}],
|
prompts=[{"prompt": "p", "multi_modal_data": {}}],
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ def test_ti2v_preprocess_uses_720p_area_for_image_condition() -> None:
|
|||||||
assert result.sampling_params.height == 672
|
assert result.sampling_params.height == 672
|
||||||
assert result.sampling_params.width == 1344
|
assert result.sampling_params.width == 1344
|
||||||
assert result.prompts[0]["multi_modal_data"]["image"].size == (1344, 672)
|
assert result.prompts[0]["multi_modal_data"]["image"].size == (1344, 672)
|
||||||
assert result.prompts[0]["additional_information"]["preprocessed_image"].shape[-2:] == (672, 1344)
|
|
||||||
|
|
||||||
|
|
||||||
def test_ti2v_diffuse_without_image_condition_expands_patch_timesteps() -> None:
|
def test_ti2v_diffuse_without_image_condition_expands_patch_timesteps() -> None:
|
||||||
|
|||||||
@@ -190,9 +190,6 @@ def get_wan22_pre_process_func(
|
|||||||
):
|
):
|
||||||
"""Pre-process function for Wan2.2: optionally load and resize input image for I2V mode."""
|
"""Pre-process function for Wan2.2: optionally load and resize input image for I2V mode."""
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from diffusers.video_processor import VideoProcessor
|
|
||||||
|
|
||||||
video_processor = VideoProcessor(vae_scale_factor=8)
|
|
||||||
|
|
||||||
def pre_process_func(request: OmniDiffusionRequest) -> OmniDiffusionRequest:
|
def pre_process_func(request: OmniDiffusionRequest) -> OmniDiffusionRequest:
|
||||||
for i, prompt in enumerate(request.prompts):
|
for i, prompt in enumerate(request.prompts):
|
||||||
@@ -236,10 +233,6 @@ def get_wan22_pre_process_func(
|
|||||||
)
|
)
|
||||||
prompt["multi_modal_data"]["image"] = image # type: ignore # key existence already checked above
|
prompt["multi_modal_data"]["image"] = image # type: ignore # key existence already checked above
|
||||||
|
|
||||||
# Preprocess for VAE
|
|
||||||
prompt["additional_information"]["preprocessed_image"] = video_processor.preprocess(
|
|
||||||
image, height=request.sampling_params.height, width=request.sampling_params.width
|
|
||||||
)
|
|
||||||
request.prompts[i] = prompt
|
request.prompts[i] = prompt
|
||||||
return request
|
return request
|
||||||
|
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ def get_wan22_i2v_pre_process_func(
|
|||||||
od_config: OmniDiffusionConfig,
|
od_config: OmniDiffusionConfig,
|
||||||
):
|
):
|
||||||
"""Pre-process function for I2V: load and resize input image."""
|
"""Pre-process function for I2V: load and resize input image."""
|
||||||
from diffusers.video_processor import VideoProcessor
|
|
||||||
|
|
||||||
video_processor = VideoProcessor(vae_scale_factor=8)
|
|
||||||
|
|
||||||
def pre_process_func(request: OmniDiffusionRequest) -> OmniDiffusionRequest:
|
def pre_process_func(request: OmniDiffusionRequest) -> OmniDiffusionRequest:
|
||||||
for i, prompt in enumerate(request.prompts):
|
for i, prompt in enumerate(request.prompts):
|
||||||
@@ -128,10 +125,6 @@ def get_wan22_i2v_pre_process_func(
|
|||||||
)
|
)
|
||||||
prompt["multi_modal_data"]["image"] = image # type: ignore # key existence already checked above
|
prompt["multi_modal_data"]["image"] = image # type: ignore # key existence already checked above
|
||||||
|
|
||||||
# Preprocess for VAE
|
|
||||||
prompt["additional_information"]["preprocessed_image"] = video_processor.preprocess(
|
|
||||||
image, height=request.sampling_params.height, width=request.sampling_params.width
|
|
||||||
)
|
|
||||||
request.prompts[i] = prompt
|
request.prompts[i] = prompt
|
||||||
return request
|
return request
|
||||||
|
|
||||||
|
|||||||
@@ -87,9 +87,6 @@ def get_wan22_ti2v_pre_process_func(
|
|||||||
od_config: OmniDiffusionConfig,
|
od_config: OmniDiffusionConfig,
|
||||||
):
|
):
|
||||||
"""Pre-process function for TI2V: optionally load and resize input image."""
|
"""Pre-process function for TI2V: optionally load and resize input image."""
|
||||||
from diffusers.video_processor import VideoProcessor
|
|
||||||
|
|
||||||
video_processor = VideoProcessor(vae_scale_factor=8)
|
|
||||||
|
|
||||||
def pre_process_func(request: OmniDiffusionRequest) -> OmniDiffusionRequest:
|
def pre_process_func(request: OmniDiffusionRequest) -> OmniDiffusionRequest:
|
||||||
for i, prompt in enumerate(request.prompts):
|
for i, prompt in enumerate(request.prompts):
|
||||||
@@ -135,10 +132,6 @@ def get_wan22_ti2v_pre_process_func(
|
|||||||
)
|
)
|
||||||
prompt["multi_modal_data"]["image"] = image # type: ignore # key existence already checked above
|
prompt["multi_modal_data"]["image"] = image # type: ignore # key existence already checked above
|
||||||
|
|
||||||
# Preprocess for VAE
|
|
||||||
prompt["additional_information"]["preprocessed_image"] = video_processor.preprocess(
|
|
||||||
image, height=request.sampling_params.height, width=request.sampling_params.width
|
|
||||||
)
|
|
||||||
request.prompts[i] = prompt
|
request.prompts[i] = prompt
|
||||||
return request
|
return request
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user