Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayan-Guan authored Sep 28, 2021
1 parent f8182d2 commit d110ff7
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions davsn/model/accel_deeplabv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit d110ff7

Please sign in to comment.