(args, model_without_ddp, optimizer, loss_scaler)
| 313 | |
| 314 | |
| 315 | def load_model(args, model_without_ddp, optimizer, loss_scaler): |
| 316 | if args.resume: |
| 317 | if args.resume.startswith('https'): |
| 318 | checkpoint = torch.hub.load_state_dict_from_url( |
| 319 | args.resume, map_location='cpu', check_hash=True) |
| 320 | else: |
| 321 | checkpoint = torch.load(args.resume, map_location='cpu') |
| 322 | model_without_ddp.load_state_dict(checkpoint['model']) |
| 323 | print("Resume checkpoint %s" % args.resume) |
| 324 | if 'optimizer' in checkpoint and 'epoch' in checkpoint and not (hasattr(args, 'eval') and args.eval): |
| 325 | optimizer.load_state_dict(checkpoint['optimizer']) |
| 326 | args.start_epoch = checkpoint['epoch'] + 1 |
| 327 | if 'scaler' in checkpoint: |
| 328 | loss_scaler.load_state_dict(checkpoint['scaler']) |
| 329 | print("With optim & sched!") |
| 330 | |
| 331 | |
| 332 | def all_reduce_mean(x): |
nothing calls this directly
no test coverage detected