| 391 | |
| 392 | |
| 393 | def main(args=None): |
| 394 | cfg = setup(args) |
| 395 | print("Command cfg:", cfg) |
| 396 | if args.eval_only: |
| 397 | model = Trainer.build_model(cfg) |
| 398 | DetectionCheckpointer(model, save_dir=cfg.OUTPUT_DIR).resume_or_load( |
| 399 | cfg.MODEL.WEIGHTS, resume=args.resume |
| 400 | ) |
| 401 | res = Trainer.test(cfg, model) |
| 402 | if cfg.TEST.AUG.ENABLED: |
| 403 | res.update(Trainer.test_with_TTA(cfg, model)) |
| 404 | return res |
| 405 | |
| 406 | trainer = Trainer(cfg) |
| 407 | if len(args.lang_weight)>0: |
| 408 | # load language weight for semantic |
| 409 | import copy |
| 410 | weight = copy.deepcopy(trainer.cfg.MODEL.WEIGHTS) |
| 411 | trainer.cfg.MODEL.WEIGHTS = args.lang_weight |
| 412 | print("load original language language weight!!!!!!") |
| 413 | trainer.resume_or_load(resume=args.resume) |
| 414 | trainer.cfg.MODEL.WEIGHTS = weight |
| 415 | print("load pretrained model weight!!!!!!") |
| 416 | trainer.resume_or_load(resume=args.resume) |
| 417 | |
| 418 | return trainer.train() |
| 419 | |
| 420 | if __name__ == "__main__": |
| 421 | # main() |