MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / motion_vis

Function motion_vis

motion_rep/motion_checker.py:403–545  ·  view source on GitHub ↗

Visualize motion by rendering a depth video. This mirrors depth_render.motion_checker.motion_vis with a narrowed dependency surface.

(
    motion_file: Optional[str] = None,
    output_dir: Optional[str] = None,
    batch_size: int = 24,
    H: int = 1024,
    W: int = 1024,
    fps: int = 20,
    motion_name: Optional[str] = None,
    recover_from_velocity: bool = False,
    zero_trans: bool = False,
    device: str = "cuda:0",
    verbose: bool = False,
    do_visulize: bool = True,
    motion_data: Optional[torch.Tensor] = None,
    video_file: Optional[str] = None,
    smpl_model_path: Optional[str] = None,
    smpl_type: str = "smplx",
)

Source from the content-addressed store, hash-verified

401
402
403def motion_vis(
404 motion_file: Optional[str] = None,
405 output_dir: Optional[str] = None,
406 batch_size: int = 24,
407 H: int = 1024,
408 W: int = 1024,
409 fps: int = 20,
410 motion_name: Optional[str] = None,
411 recover_from_velocity: bool = False,
412 zero_trans: bool = False,
413 device: str = "cuda:0",
414 verbose: bool = False,
415 do_visulize: bool = True,
416 motion_data: Optional[torch.Tensor] = None,
417 video_file: Optional[str] = None,
418 smpl_model_path: Optional[str] = None,
419 smpl_type: str = "smplx",
420):
421 """
422 Visualize motion by rendering a depth video.
423 This mirrors depth_render.motion_checker.motion_vis with a narrowed dependency surface.
424 """
425 # Override H, W, fps from video if provided
426 if video_file is not None and os.path.exists(video_file):
427 W, H, fps = get_video_properties(video_file)
428 if verbose:
429 print(f"Using video properties: W={W}, H={H}, fps={fps}")
430
431 if motion_data is None:
432 motion_data = torch.load(motion_file, map_location=device, weights_only=True)
433 if motion_name is None and motion_file is not None:
434 motion_name = os.path.basename(motion_file).split(".")[0]
435 elif motion_name is None:
436 motion_name = "motion"
437
438 if isinstance(motion_data, dict):
439 if verbose:
440 print("Reading training data")
441 motion = motion_data["motion"]
442 smpl_params, joints = motion_rep_to_SMPL(motion, recover_from_velocity)
443 extrinsic = motion_data["extrinsic"]
444 R, T = extrinsic.split([6, 3], dim=-1)
445 R = rot6d_to_mat3x3(R)
446 intrinsic = motion_data.get("intrinsic", None)
447 if intrinsic is None:
448 intrinsic = torch.tensor(
449 [
450 [estimate_focal_length(W, H), 0, W / 2],
451 [0, estimate_focal_length(W, H), H / 2],
452 [0, 0, 1],
453 ]
454 ).float()
455 else:
456 if verbose:
457 print("Reading testing data")
458 if motion_data.shape[1] == 276:
459 motion = motion_data
460 smpl_params, joints = motion_rep_to_SMPL(motion, recover_from_velocity)

Callers 2

save_motion_dictMethod · 0.90
mainFunction · 0.85

Calls 8

motion_rep_to_SMPLFunction · 0.90
rot6d_to_mat3x3Function · 0.90
get_video_propertiesFunction · 0.85
estimate_focal_lengthFunction · 0.85
get_R_TFunction · 0.85
_default_smpl_model_pathFunction · 0.85
render_and_save_overlayFunction · 0.85
render_and_saveFunction · 0.85

Tested by

no test coverage detected