MCPcopy Create free account
hub / github.com/Haochen-Wang409/U2PL / net_process

Function net_process

eval.py:159–181  ·  view source on GitHub ↗
(model, image)

Source from the content-addressed store, hash-verified

157
158@torch.no_grad()
159def 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
184def scale_crop_process(model, image, classes, crop_h, crop_w, h, w, stride_rate=2 / 3):

Callers 2

scale_crop_processFunction · 0.70
scale_whole_processFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected