-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathviewer.py
More file actions
71 lines (61 loc) · 2.04 KB
/
viewer.py
File metadata and controls
71 lines (61 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import sys
from pathlib import Path
import click
import rerun as rr
from loguru import logger
from nymeria.data_provider import NymeriaDataProvider
from nymeria.data_viewer import NymeriaViewer
from nymeria.definitions import BodyModel
@click.command()
@click.option(
"-i", "sequence_dir", type=Path, required=True, help="The directory of sequence "
)
@click.option(
"-s", "save_rrd", is_flag=True, default=False, help="Save rerun into logfile"
)
@click.option(
"--body-model",
"body_model",
type=click.Choice(["momentum", "smpl", "mhr"], case_sensitive=False),
default="momentum",
help="Body model to use: momentum (default), smpl, or mhr",
)
@click.option(
"--smpl-model-path",
"smpl_model_path",
type=Path,
default=None,
help="Path to SMPL model .pkl file (required when --body-model=smpl)",
)
def main(
sequence_dir: Path, save_rrd: bool, body_model: str, smpl_model_path: Path
) -> None:
logger.remove()
logger.add(
sys.stdout,
colorize=True,
format="<level>{level: <7}</level> <blue>{name}.py:</blue><green>{function}</green><yellow>:{line}</yellow> {message}",
level="INFO",
)
if body_model == "smpl" and smpl_model_path is None:
raise click.UsageError("--smpl-model-path is required when --body-model=smpl")
# See NymeriaDataProviderConfig for configuration
nymeria_dp = NymeriaDataProvider(
sequence_rootdir=sequence_dir,
load_wrist=True,
body_model=BodyModel(body_model),
smpl_model_path=str(smpl_model_path) if smpl_model_path else None,
)
output_rrd: Path = sequence_dir / "nymeria.rrd" if save_rrd else None
viewer = NymeriaViewer(output_rrd=output_rrd)
viewer(nymeria_dp)
if save_rrd:
logger.info(f"Save visualization to {output_rrd=}")
rr.disconnect()
if __name__ == "__main__":
main()