(state_dict)
| 422 | |
| 423 | # original saved file with DataParallel |
| 424 | def remove_module(state_dict): |
| 425 | # create new OrderedDict that does not contain `module.` |
| 426 | new_state_dict = OrderedDict() |
| 427 | for k, v in state_dict.items(): |
| 428 | name = k[7:] # remove `module.` |
| 429 | new_state_dict[name] = v |
| 430 | return new_state_dict |
| 431 | |
| 432 | def tensor2image(tensor): |
| 433 | image = tensor.detach().cpu().numpy() |