(model, image)
| 157 | |
| 158 | @torch.no_grad() |
| 159 | def net_process(model, image): |
| 160 | b, c, h, w = image.shape |
| 161 | # num_classes = cfg['net']['num_classes'] |
| 162 | # output_all = torch.zeros((6, b, num_classes, h, w)).cuda() |
| 163 | input = image.cuda() |
| 164 | output = model(input)["pred"] |
| 165 | output = F.interpolate(output, (h, w), mode="bilinear", align_corners=True) |
| 166 | # output_all[0] = F.softmax(output, dim=1) |
| 167 | # |
| 168 | # output = model(torch.flip(input, [3]))["pred"] |
| 169 | # output = F.interpolate(output, (h, w), mode="bilinear", align_corners=True) |
| 170 | # output = F.softmax(output, dim=1) |
| 171 | # output_all[1] = torch.flip(output, [3]) |
| 172 | # |
| 173 | # scales = [(961, 961), (841, 841), (721, 721), (641, 641)] |
| 174 | # for k, scale in enumerate(scales): |
| 175 | # input_scale = F.interpolate(input, scale, mode="bilinear", align_corners=True) |
| 176 | # output = model(input_scale)["pred"] |
| 177 | # output = F.interpolate(output, (h, w), mode="bilinear", align_corners=True) |
| 178 | # output_all[k + 2] = F.softmax(output, dim=1) |
| 179 | # |
| 180 | # output = torch.mean(output_all, dim=0) |
| 181 | return output |
| 182 | |
| 183 | |
| 184 | def scale_crop_process(model, image, classes, crop_h, crop_w, h, w, stride_rate=2 / 3): |
no outgoing calls
no test coverage detected