(opt)
| 483 | |
| 484 | |
| 485 | def main(opt): |
| 486 | |
| 487 | if opt.category == 'airplane': |
| 488 | opt.beta_start = 1e-5 |
| 489 | opt.beta_end = 0.008 |
| 490 | opt.schedule_type = 'warm0.1' |
| 491 | |
| 492 | exp_id = os.path.splitext(os.path.basename(__file__))[0] |
| 493 | dir_id = os.path.dirname(__file__) |
| 494 | output_dir = get_output_dir(dir_id, exp_id) |
| 495 | copy_source(__file__, output_dir) |
| 496 | logger = setup_logging(output_dir) |
| 497 | |
| 498 | outf_syn, = setup_output_subdirs(output_dir, 'syn') |
| 499 | |
| 500 | betas = get_betas(opt.schedule_type, opt.beta_start, opt.beta_end, opt.time_num) |
| 501 | model = Model(opt, betas, opt.loss_type, opt.model_mean_type, opt.model_var_type) |
| 502 | |
| 503 | if opt.cuda: |
| 504 | model.cuda() |
| 505 | |
| 506 | def _transform_(m): |
| 507 | return nn.parallel.DataParallel(m) |
| 508 | |
| 509 | model = model.cuda() |
| 510 | model.multi_gpu_wrapper(_transform_) |
| 511 | |
| 512 | model.eval() |
| 513 | |
| 514 | with torch.no_grad(): |
| 515 | |
| 516 | logger.info("Resume Path:%s" % opt.model) |
| 517 | |
| 518 | resumed_param = torch.load(opt.model) |
| 519 | model.load_state_dict(resumed_param['model_state']) |
| 520 | |
| 521 | |
| 522 | ref = None |
| 523 | if opt.generate: |
| 524 | opt.eval_path = os.path.join(outf_syn, 'samples.pth') |
| 525 | Path(opt.eval_path).parent.mkdir(parents=True, exist_ok=True) |
| 526 | ref=generate(model, opt) |
| 527 | |
| 528 | if opt.eval_gen: |
| 529 | # Evaluate generation |
| 530 | evaluate_gen(opt, ref, logger) |
| 531 | |
| 532 | |
| 533 | def parse_args(): |
no test coverage detected