()
| 100 | |
| 101 | |
| 102 | def train_args(): |
| 103 | parser = argparse.ArgumentParser() |
| 104 | add_base_options(parser) |
| 105 | add_encoding_training_options(parser) |
| 106 | add_diffusion_training_options(parser) |
| 107 | args = parser.parse_args() |
| 108 | |
| 109 | # check existence |
| 110 | if os.path.exists(args.tag): |
| 111 | response = input(f'Folder "{args.tag}" already exists, continue? (y/n) ') |
| 112 | if response != 'y': |
| 113 | exit() |
| 114 | |
| 115 | os.makedirs(args.tag, exist_ok=True) |
| 116 | enc_log_dir = encoding_log_dir(args.tag) |
| 117 | diff_log_dir = diffusion_log_dir(args.tag) |
| 118 | |
| 119 | # encoding part |
| 120 | if args.enc_log is not None: # use existing encoding, load args |
| 121 | load_and_overwrite_args(args, os.path.join(args.enc_log, "args.json")) |
| 122 | if not os.path.exists(enc_log_dir): |
| 123 | os.symlink(os.path.abspath(args.enc_log), enc_log_dir) |
| 124 | else: |
| 125 | os.makedirs(enc_log_dir, exist_ok=True) |
| 126 | save_path = os.path.join(enc_log_dir, "args.json") |
| 127 | with open(save_path, "w") as f: |
| 128 | json.dump(get_args_by_group(parser, args, "encoding"), f, indent=4) |
| 129 | |
| 130 | # diffusion part |
| 131 | args.in_channels = args.fdim_geo if args.data_type == "sdf" else args.fdim_geo + args.fdim_tex |
| 132 | args.out_channels = args.fdim_geo if args.data_type == "sdf" else args.fdim_geo + args.fdim_tex |
| 133 | os.makedirs(diff_log_dir, exist_ok=True) |
| 134 | save_path = os.path.join(diff_log_dir, "args.json") |
| 135 | with open(save_path, "w") as f: |
| 136 | json.dump(get_args_by_group(parser, args, "diffusion"), f, indent=4) |
| 137 | |
| 138 | # assert args.in_channels == args.out_channels == args.fdim_geo + args.fdim_tex |
| 139 | |
| 140 | # print all args |
| 141 | print("----- Training args -----") |
| 142 | for k, v in args.__dict__.items(): |
| 143 | print("{0:20}".format(k), v) |
| 144 | |
| 145 | return args |
| 146 | |
| 147 | |
| 148 | def sample_args(): |
no test coverage detected