Main function to spawn the train and test process.
()
| 23 | |
| 24 | |
| 25 | def main(): |
| 26 | """ |
| 27 | Main function to spawn the train and test process. |
| 28 | """ |
| 29 | args = parse_args() |
| 30 | |
| 31 | if 'SLURM_STEP_NODELIST' in os.environ: |
| 32 | args.init_method = "tcp://{}:{}".format( |
| 33 | parse_ip(os.environ['SLURM_STEP_NODELIST']), "9999") |
| 34 | |
| 35 | print("Init Method: {}".format(args.init_method)) |
| 36 | |
| 37 | cfg = load_config(args) |
| 38 | cfg = assert_and_infer_cfg(cfg) |
| 39 | |
| 40 | cfg.NUM_SHARDS = int(os.environ['SLURM_NTASKS']) |
| 41 | cfg.SHARD_ID = int(os.environ['SLURM_NODEID']) |
| 42 | |
| 43 | print(f'node id > {cfg.SHARD_ID}') |
| 44 | else: |
| 45 | cfg = load_config(args) |
| 46 | cfg = assert_and_infer_cfg(cfg) |
| 47 | |
| 48 | # Perform training. |
| 49 | if cfg.TRAIN.ENABLE: |
| 50 | launch_job(cfg=cfg, init_method=args.init_method, func=train) |
| 51 | |
| 52 | # Perform multi-clip testing. |
| 53 | if cfg.TEST.ENABLE: |
| 54 | launch_job(cfg=cfg, init_method=args.init_method, func=test) |
| 55 | |
| 56 | # Perform model visualization. |
| 57 | if cfg.TENSORBOARD.ENABLE and ( |
| 58 | cfg.TENSORBOARD.MODEL_VIS.ENABLE |
| 59 | or cfg.TENSORBOARD.WRONG_PRED_VIS.ENABLE |
| 60 | ): |
| 61 | launch_job(cfg=cfg, init_method=args.init_method, func=visualize) |
| 62 | |
| 63 | # Run demo. |
| 64 | # if cfg.DEMO.ENABLE: |
| 65 | # demo(cfg) |
| 66 | |
| 67 | |
| 68 | if __name__ == "__main__": |
no test coverage detected