MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / forward

Method forward

network/hrnetv2.py:399–449  ·  view source on GitHub ↗
(self, x_in)

Source from the content-addressed store, hash-verified

397 return nn.Sequential(*modules), num_inchannels
398
399 def forward(self, x_in):
400 x = self.conv1(x_in)
401 x = self.bn1(x)
402 x = self.relu(x)
403 x = self.conv2(x)
404 x = self.bn2(x)
405 x = self.relu(x)
406 x = self.layer1(x)
407
408 x_list = []
409 for i in range(self.stage2_cfg['NUM_BRANCHES']):
410 if self.transition1[i] is not None:
411 x_list.append(self.transition1[i](x))
412 else:
413 x_list.append(x)
414 y_list = self.stage2(x_list)
415
416 x_list = []
417 for i in range(self.stage3_cfg['NUM_BRANCHES']):
418 if self.transition2[i] is not None:
419 if i < self.stage2_cfg['NUM_BRANCHES']:
420 x_list.append(self.transition2[i](y_list[i]))
421 else:
422 x_list.append(self.transition2[i](y_list[-1]))
423 else:
424 x_list.append(y_list[i])
425 y_list = self.stage3(x_list)
426
427 x_list = []
428 for i in range(self.stage4_cfg['NUM_BRANCHES']):
429 if self.transition3[i] is not None:
430 if i < self.stage3_cfg['NUM_BRANCHES']:
431 x_list.append(self.transition3[i](y_list[i]))
432 else:
433 x_list.append(self.transition3[i](y_list[-1]))
434 else:
435 x_list.append(y_list[i])
436 x = self.stage4(x_list)
437
438 # Upsampling
439 x0_h, x0_w = x[0].size(2), x[0].size(3)
440 x1 = F.interpolate(x[1], size=(x0_h, x0_w),
441 mode='bilinear', align_corners=align_corners)
442 x2 = F.interpolate(x[2], size=(x0_h, x0_w),
443 mode='bilinear', align_corners=align_corners)
444 x3 = F.interpolate(x[3], size=(x0_h, x0_w),
445 mode='bilinear', align_corners=align_corners)
446
447 feats = torch.cat([x[0], x1, x2, x3], 1)
448
449 return None, None, feats
450
451 def init_weights(self, pretrained=cfg.MODEL.HRNET_CHECKPOINT):
452 logx.msg('=> init weights from normal distribution')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected