| 93 | |
| 94 | |
| 95 | def load_model(opt, checkpoint): |
| 96 | # since model goes between -4 and 4 instead of -0.5 to 0.5 |
| 97 | sample_frequency = 3*(opt.img_size/4,) |
| 98 | |
| 99 | if opt.multiscale: |
| 100 | # scale the frequencies of each layer accordingly |
| 101 | input_scales = [1/24, 1/24, 1/24, 1/16, 1/16, 1/8, 1/8, 1/4, 1/4] |
| 102 | output_layers = [2, 4, 6, 8] |
| 103 | |
| 104 | with utils.HiddenPrint(): |
| 105 | model = modules.MultiscaleBACON(3, opt.hidden_features, 4, |
| 106 | hidden_layers=opt.hidden_layers, |
| 107 | bias=True, |
| 108 | frequency=sample_frequency, |
| 109 | quantization_interval=np.pi/4, |
| 110 | input_scales=input_scales, |
| 111 | output_layers=output_layers, |
| 112 | reuse_filters=opt.reuse_filters) |
| 113 | model.cuda() |
| 114 | |
| 115 | print('Loading checkpoints') |
| 116 | state_dict = torch.load(checkpoint) |
| 117 | model.load_state_dict(state_dict, strict=False) |
| 118 | |
| 119 | models = {'combined': model} |
| 120 | |
| 121 | return models |
| 122 | |
| 123 | |
| 124 | def render_in_chunks(in_dict, model, chunk_size, return_all=False): |