From 227444a6b4f16b29e1c8337563a1bae99b2ad943 Mon Sep 17 00:00:00 2001 From: aiihn <101506918+aiihn@users.noreply.github.com> Date: Wed, 25 Mar 2026 06:28:07 +0800 Subject: [PATCH] Enhance HunyuanWorldPlayOperator and Pipeline with configurable motion parameters - Added forward_speed, yaw_speed_deg, and pitch_speed_deg as parameters to HunyuanWorldPlayOperator and HunyuanWorldPlayPipeline. - Updated the initialization of HunyuanWorldPlayOperator to accept new parameters. - Modified the pipeline to pass motion parameters to the operator and allow runtime adjustments. - Updated tests to include new parameters for consistency in behavior. --- .../operators/hunyuan_worldplay_operator.py | 19 +++++++++++++++---- .../pipeline_hunyuan_worldplay.py | 19 ++++++++++++++++++- test/test_hunyuan_worldplay.py | 3 +++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/openworldlib/operators/hunyuan_worldplay_operator.py b/src/openworldlib/operators/hunyuan_worldplay_operator.py index c8c97c03..562b38dc 100644 --- a/src/openworldlib/operators/hunyuan_worldplay_operator.py +++ b/src/openworldlib/operators/hunyuan_worldplay_operator.py @@ -15,10 +15,21 @@ class HunyuanWorldPlayOperator(BaseOperator): - def __init__(self, operation_types=None, interaction_template=None): + def __init__( + self, + operation_types=None, + interaction_template=None, + *, + forward_speed: float = 0.08, + yaw_speed_deg: float = 3.0, + pitch_speed_deg: float = 3.0, + ): if operation_types is None: operation_types = ["action_instruction"] super().__init__(operation_types=operation_types) + self.forward_speed = forward_speed + self.yaw_speed_deg = yaw_speed_deg + self.pitch_speed_deg = pitch_speed_deg self.interaction_template = interaction_template or [ "forward", "backward", @@ -117,9 +128,9 @@ def _is_action_sequence(self, interaction) -> bool: return all(item in self.interaction_template for item in interaction) def _actions_to_pose_json(self, actions: list[str]) -> dict: - forward_speed = 0.08 - yaw_speed = np.deg2rad(3) - pitch_speed = np.deg2rad(3) + forward_speed = self.forward_speed + yaw_speed = np.deg2rad(self.yaw_speed_deg) + pitch_speed = np.deg2rad(self.pitch_speed_deg) motions: list[dict] = [] for action in actions: move = {} diff --git a/src/openworldlib/pipelines/hunyuan_world/pipeline_hunyuan_worldplay.py b/src/openworldlib/pipelines/hunyuan_world/pipeline_hunyuan_worldplay.py index 02d98757..980a938b 100644 --- a/src/openworldlib/pipelines/hunyuan_world/pipeline_hunyuan_worldplay.py +++ b/src/openworldlib/pipelines/hunyuan_world/pipeline_hunyuan_worldplay.py @@ -38,6 +38,9 @@ def from_pretrained( overlap_group_offloading: bool = True, init_infer_state: bool = True, infer_state_kwargs: Optional[dict] = None, + forward_speed: float = 0.08, + yaw_speed_deg: float = 3.0, + pitch_speed_deg: float = 3.0, **kwargs ) -> 'HunyuanWorldPlayPipeline': """ @@ -90,7 +93,11 @@ def from_pretrained( action_ckpt=model_path, **kwargs ) - operators = HunyuanWorldPlayOperator() + operators = HunyuanWorldPlayOperator( + forward_speed=forward_speed, + yaw_speed_deg=yaw_speed_deg, + pitch_speed_deg=pitch_speed_deg, + ) return cls( synthesis_model=synthesis_model, @@ -165,6 +172,9 @@ def __call__( model_type: str = "ar", user_height: Optional[int] = None, user_width: Optional[int] = None, + forward_speed: Optional[float] = None, + yaw_speed_deg: Optional[float] = None, + pitch_speed_deg: Optional[float] = None, **kwargs ): """ @@ -194,6 +204,13 @@ def __call__( Returns: HunyuanVideoPipelineOutput: 包含生成的视频帧 """ + if forward_speed is not None: + self.operators.forward_speed = forward_speed + if yaw_speed_deg is not None: + self.operators.yaw_speed_deg = yaw_speed_deg + if pitch_speed_deg is not None: + self.operators.pitch_speed_deg = pitch_speed_deg + video_length = num_frames pose_value = interactions if interactions is not None else pose if pose_value is None: diff --git a/test/test_hunyuan_worldplay.py b/test/test_hunyuan_worldplay.py index 4de39184..616f9dec 100644 --- a/test/test_hunyuan_worldplay.py +++ b/test/test_hunyuan_worldplay.py @@ -21,6 +21,9 @@ prompt=prompt, image_path=image_path, interactions=interaction_signal, + forward_speed=0.08, + yaw_speed_deg=3.0, + pitch_speed_deg=3.0, ) save_video_path = os.path.join(output_path, "hunyuan_worldplay_demo.mp4")