File size: 4,469 Bytes
fe64bad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
import os

from src.models.tools.jointstypes import JOINTSTYPES
from .base import ArgumentParser, add_cuda_options, adding_cuda
from .tools import load_args
from .dataset import add_dataset_options


def construct_figname(parameters):
    figname = "fig_{:03d}"
    return figname


def add_visualize_options(parser):
    group = parser.add_argument_group('Visualization options')
    group.add_argument("--num_actions_to_sample", default=5, type=int, help="num actions to sample")
    group.add_argument("--num_samples_per_action", default=5, type=int, help="num samples per action")
    group.add_argument("--fps", default=20, type=int, help="FPS for the rendering")
    group.add_argument("--appearance_mode", default='motionclip', choices=['motionclip', 'original'], type=str,
                       help="How the stick figures will appear")

    group.add_argument("--force_visu_joints", dest='force_visu_joints', action='store_true',
                       help="if we want to visualize joints even if it is rotation")
    group.add_argument('--no-force_visu_joints', dest='force_visu_joints', action='store_false',
                       help="if we don't want to visualize joints even if it is rotation")
    group.set_defaults(force_visu_joints=True)

    group.add_argument("--jointstype", default="smpl", choices=JOINTSTYPES,
                       help="Jointstype for training with xyz")
    group.add_argument('--vertstrans', dest='vertstrans', action='store_true', help="Training with vertex translations")
    group.add_argument('--no-vertstrans', dest='vertstrans', action='store_false',
                       help="Training without vertex translations")
    group.set_defaults(vertstrans=False)

    group.add_argument("--noise_same_action", default="random",
                       choices=["interpolate", "random", "same"],
                       help="inside one action, sample several noise or interpolate it")

    group.add_argument("--noise_diff_action", default="random",
                       choices=["random", "same"],
                       help="use the same noise or different noise for every actions")

    group.add_argument("--duration_mode", default="mean",
                       choices=["mean", "interpolate"],
                       help="use the same noise or different noise for every actions")

    group.add_argument("--reconstruction_mode", default="ntf",
                       choices=["tf", "ntf", "both"],
                       help="reconstruction: teacher forcing or not or both")

    group.add_argument("--decoder_test", default="new",
                       choices=["new", "diffaction", "diffduration", "interpolate_action"],
                       help="what is the test we want to do")

    group.add_argument("--fact_latent", type=int, default=1,
                       help="factor for max latent space")

    group.add_argument("--images_dir", type=str, default='./action_images',
                       help="dir with images for clip visualization")

    group.add_argument("--input_file", default=None, help="Input txt/csv file defining generation. For more info, see README.")

    group.add_argument("--zero_global_orient", action='store_true', help="will set global orientation to zero")
    group.add_argument("--ae_after_generation", action='store_true', help="Apply auto encoding after generation to project motion into motion manifold.")


def parser(checkpoint=True):
    parser = ArgumentParser()
    if checkpoint:
        parser.add_argument("checkpointname")
    else:
        add_dataset_options(parser)

    # add visualize options back
    add_visualize_options(parser)

    # cuda options
    add_cuda_options(parser)

    opt = parser.parse_args()
    if checkpoint:
        newparameters = {key: val for key, val in vars(opt).items() if val is not None}
        folder, checkpoint = os.path.split(newparameters["checkpointname"])
        parameters = load_args(os.path.join(folder, "opt.yaml"))
        parameters.update(newparameters)
    else:
        parameters = {key: val for key, val in vars(opt).items() if val is not None}

    adding_cuda(parameters)

    if checkpoint:
        parameters["figname"] = construct_figname(parameters)
        epoch = int(checkpoint.split("_")[-1].split('.')[0])
        return parameters, folder, checkpoint, epoch
    else:
        return parameters