pose ¶
Pose processing utilities for HYWorld video generation.
This module provides functions to convert camera poses to model input tensors, including viewmats, intrinsics, and action labels.
Adapted from HY-WorldPlay: https://github.com/Tencent-Hunyuan/HY-WorldPlay
Functions:¶
fastvideo.models.dits.hyworld.pose.camera_center_normalization ¶
Normalize camera centers relative to the first camera.
Source code in fastvideo/models/dits/hyworld/pose.py
fastvideo.models.dits.hyworld.pose.compute_latent_num ¶
Compute the number of latents from number of frames.
Formula: num_frames = (latent_num - 1) * 4 + 1 So: latent_num = (num_frames - 1) // 4 + 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_frames | int | Number of video frames | required |
Returns:
| Type | Description |
|---|---|
int | Number of latents |
Source code in fastvideo/models/dits/hyworld/pose.py
fastvideo.models.dits.hyworld.pose.compute_num_frames ¶
fastvideo.models.dits.hyworld.pose.one_hot_to_one_dimension ¶
Convert one-hot action encoding to single dimension labels.
fastvideo.models.dits.hyworld.pose.parse_pose_string ¶
parse_pose_string(pose_string: str, forward_speed: float = DEFAULT_FORWARD_SPEED, yaw_speed: float = DEFAULT_YAW_SPEED, pitch_speed: float = DEFAULT_PITCH_SPEED) -> list[dict]
Parse pose string to motions list.
Format: "w-3, right-0.5, d-4" - w: forward movement - s: backward movement - a: left movement - d: right movement - up: pitch up rotation - down: pitch down rotation - left: yaw left rotation - right: yaw right rotation - number after dash: duration in frames/latents
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_string | str | Comma-separated pose commands | required |
forward_speed | float | Movement amount per frame | DEFAULT_FORWARD_SPEED |
yaw_speed | float | Yaw rotation amount per frame (radians) | DEFAULT_YAW_SPEED |
pitch_speed | float | Pitch rotation amount per frame (radians) | DEFAULT_PITCH_SPEED |
Returns:
| Type | Description |
|---|---|
list[dict] | List of motion dictionaries for generate_camera_trajectory_local |
Source code in fastvideo/models/dits/hyworld/pose.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
fastvideo.models.dits.hyworld.pose.parse_pose_string_to_actions ¶
Parse pose string to frame-level action timeline.
Format: pose string uses latent counts, where: - 1 latent = 4 frames - Special rule: first frame of entire video is extra (frame 0) - Example: "w-4,d-4" means: - w-4: forward for frames 0-16 (17 frames total: 1 extra + 44) - d-4: right for frames 17-32 (16 frames total: 44)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_string | str | Comma-separated pose commands (e.g., "w-4,d-4") | required |
fps | int | Frames per second for video (default: 24) | 24 |
Returns:
| Type | Description |
|---|---|
list[dict] | List of dicts with action values for each frame |
Source code in fastvideo/models/dits/hyworld/pose.py
fastvideo.models.dits.hyworld.pose.pose_string_to_json ¶
Convert pose string to pose JSON format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_string | str | Comma-separated pose commands | required |
intrinsic | Optional[list[list[float]]] | Camera intrinsic matrix (default: DEFAULT_INTRINSIC from trajectory) | None |
Returns:
| Type | Description |
|---|---|
dict | Dict with frame indices as keys, containing extrinsic and K (intrinsic) matrices |
Source code in fastvideo/models/dits/hyworld/pose.py
fastvideo.models.dits.hyworld.pose.pose_to_input ¶
pose_to_input(pose_data: Union[str, dict], latent_num: int, tps: bool = False) -> tuple[Tensor, Tensor, Tensor]
Convert pose data to model input tensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_data | Union[str, dict] | One of: - str ending with '.json': path to JSON file - str: pose string (e.g., "w-3, right-0.5, d-4") - dict: pose JSON data | required |
latent_num | int | Number of latents (frames in latent space) | required |
tps | bool | Third-person mode flag | False |
Returns:
| Type | Description |
|---|---|
tuple[Tensor, Tensor, Tensor] | Tuple of (viewmats, intrinsics, action_labels): - viewmats: World-to-camera matrices [T, 4, 4] - intrinsics: Normalized camera intrinsics [T, 3, 3] - action_labels: Action labels for each frame [T] |
Source code in fastvideo/models/dits/hyworld/pose.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |