def execute(self, x): imsize = x.shape x_, x__, x_0, x = self.backbone(x) ## begin ocrhead context = self.get_context(x_0) x_feature = self.conv_3x3(x) x = self.head(context, x_feature) x = nn.resize(x, size=(imsize[2], imsize[3]), mode='bilinear') context = nn.resize(context, size=(imsize[2], imsize[3]), mode='bilinear') return context, x
def execute(self, x): imsize = x.shape _, _, _, x = self.backbone(x) x = self.head(x) x = nn.resize(x, size=(imsize[2], imsize[3]), mode='bilinear') return x
def execute(self, x): imsize = x.shape _, _, _, x = self.backbone(x) b, c, h, w = x.shape x_k = self.conv_0(x) x1 = self.layer5a(x_k).reshape(b, c, -1) x2 = self.layer5b(x_k).reshape(b, c, -1) x3 = self.layer5c(x_k).reshape(b, c, -1) x4 = self.layer5d(x_k).reshape(b, c, -1) x_k = concat([x1, x2, x3, x4], 2).transpose(0, 2, 1) # b 110 c x_q = self.conv_1(x) x_q = x_q.reshape(b, c, -1) x_attention = nn.bmm(x_k, x_q) # b 110 N x_v = self.conv_2(x) x1 = self.layer5a(x_v).reshape(b, c, -1) x2 = self.layer5b(x_v).reshape(b, c, -1) x3 = self.layer5c(x_v).reshape(b, c, -1) x4 = self.layer5d(x_v).reshape(b, c, -1) x_v = concat([x1, x2, x3, x4], 2) # b c 110 x = nn.bmm(x_v, x_attention).reshape(b, c, h, w) x = self.final_conv(x) x = nn.resize(x, size=(imsize[2], imsize[3]), mode='bilinear', align_corners=True) return x
def execute(self, input): x, low_level_feat = self.backbone(input) x = self.aspp(x) x = self.decoder(x, low_level_feat) x = nn.resize(x, size=(input.shape[2], input.shape[3]), mode='bilinear') return x
def interpolate(X, size=None, scale_factor=None, mode='bilinear', align_corners=False): if scale_factor is not None: size = [X.shape[-2] * scale_factor, X.shape[-1] * scale_factor] if isinstance(size, int): size = (size, size) return nn.resize(X, size, mode, align_corners)
def execute(self, x, low_level_feat): low_level_feat = self.conv1(low_level_feat) low_level_feat = self.bn1(low_level_feat) low_level_feat = self.relu(low_level_feat) #print (low_level_feat.shape) x = nn.resize(x, size=(low_level_feat.shape[2], low_level_feat.shape[3]), mode='bilinear') x = concat((x, low_level_feat), dim=1) x = self.last_conv(x) return x
def execute(self, x): size = x.shape _, _, _, x = self.backbone(x) x = self.final_conv( concat([ x, self.layer5a(x), self.layer5b(x), self.layer5c(x), self.layer5d(x), ], 1)) return nn.resize(x, size=(size[2], size[3]), mode='bilinear')
def execute(self, x): size = x.shape output = nn.resize(self.conv(x), size=(size[2], size[3]), mode='bilinear') return output