From d110ff70dacec4156a3787eb49e7f2448dfb91a5 Mon Sep 17 00:00:00 2001 From: Dayan-Guan <75825029+Dayan-Guan@users.noreply.github.com> Date: Tue, 28 Sep 2021 15:42:57 +0800 Subject: [PATCH] Add files via upload --- davsn/model/accel_deeplabv2.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/davsn/model/accel_deeplabv2.py b/davsn/model/accel_deeplabv2.py index a1f2de5..b870619 100644 --- a/davsn/model/accel_deeplabv2.py +++ b/davsn/model/accel_deeplabv2.py @@ -42,10 +42,8 @@ def forward(self, x): residual = self.downsample(x) out += residual out = self.relu(out) - return out - class ClassifierModule(nn.Module): def __init__(self, inplanes, dilation_series, padding_series, num_classes): super(ClassifierModule, self).__init__() @@ -64,7 +62,6 @@ def forward(self, x): out += self.conv2d_list[i + 1](x) return out - class ResNetMulti(nn.Module): def __init__(self, block, layers, num_classes, multi_level): self.multi_level = multi_level @@ -116,25 +113,8 @@ def _make_layer(self, block, planes, blocks, stride=1, dilation=1): self.inplanes = planes * block.expansion for i in range(1, blocks): layers.append(block(self.inplanes, planes, dilation=dilation)) - return nn.Sequential(*layers) - # def forward(self, x): - # x = self.conv1(x) - # x = self.bn1(x) - # x = self.relu(x) - # x = self.maxpool(x) - # x = self.layer1(x) - # x = self.layer2(x) - # x = self.layer3(x) - # if self.multi_level: - # x1 = self.layer5(x) # produce segmap 1 - # else: - # x1 = None - # x2 = self.layer4(x) - # x2 = self.layer6(x2) # produce segmap 2 - # return x1, x2 - def forward(self, cf, kf, flow, device): cf = self.conv1(cf) cf = self.bn1(cf) @@ -175,8 +155,8 @@ def forward(self, cf, kf, flow, device): rec_positions = np.zeros(cf.shape) for x in range(cf.shape[-1]): for y in range(cf.shape[-2]): - x_flow = int(round(x + flow_cf[:, 0, y, x][0])) - y_flow = int(round(y + flow_cf[:, 1, y, x][0])) + x_flow = int(round(x - flow_cf[:, 0, y, x][0])) + y_flow = int(round(y - flow_cf[:, 1, y, x][0])) if x_flow >= 0 and x_flow < flow_cf.shape[-1] and y_flow >= 0 and y_flow < flow_cf.shape[-2]: kf_aux_rec[:, :, y_flow, x_flow] = kf_aux_cpu[:, :, y, x] kf_rec[:, :, y_flow, x_flow] = kf_cpu[:, :, y, x] @@ -185,6 +165,7 @@ def forward(self, cf, kf, flow, device): kf_rec = torch.from_numpy(kf_rec) rec_positions = torch.from_numpy(rec_positions) + pred_aux = self.sf_layer(torch.cat((cf_aux, (rec_positions*kf_aux_rec).float().cuda(device)), dim=1)) pred = self.sf_layer(torch.cat((cf, (rec_positions*kf_rec).float().cuda(device)), dim=1)) return pred_aux, pred, cf_aux, cf, kf_aux, kf @@ -197,7 +178,6 @@ def get_1x_lr_params_no_scale(self): any batchnorm parameter """ b = [] - b.append(self.conv1) b.append(self.bn1) b.append(self.layer1)