MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / forward

Method forward

script/feature/model.py:321–367  ·  view source on GitHub ↗
(self, x, upsampleH, upsampleW)

Source from the content-addressed store, hash-verified

319 )
320
321 def forward(self, x, upsampleH, upsampleW): #
322 feat = []
323 feat_out = [] # we only use high level features
324 for i in range(len(self.encoder)):
325 # print("layer {} encoder layer: {}".format(i, self.encoder[i]))
326 x = self.encoder[i](x)
327 if i == 3: # ReLU-4
328 feat.append(x)
329 elif i == 8: # ReLU-9
330 feat.append(x)
331 elif i == 17: # ReLU-18
332 feat.append(x)
333 elif i == 26: # ReLU-27
334 feat.append(x)
335 elif i == 35: # ReLU-36
336 feat.append(x)
337
338 for i in range(len(self.decoder)):
339 # print("layer {} decoder layer: {}".format(i, self.decoder[i]))
340 x = self.decoder[i](x)
341 if i == 1:
342 _, _, h, w = feat[4].shape
343 x = nn.UpsamplingBilinear2d(size=(h,w))(x)
344 x = x + feat[4]
345 elif i == 3:
346 _, _, h, w = feat[3].shape
347 x = nn.UpsamplingBilinear2d(size=(h,w))(x)
348 x = x + feat[3]
349 elif i == 5:
350 _, _, h, w = feat[2].shape
351 x = nn.UpsamplingBilinear2d(size=(h,w))(x)
352 x = x + feat[2]
353 feature = torch.mean(torch.nn.UpsamplingBilinear2d(size=(upsampleH, upsampleW))(x), dim=1)
354 feat_out.append(feature)
355 elif i == 7:
356 _, _, h, w = feat[1].shape
357 x = nn.UpsamplingBilinear2d(size=(h,w))(x)
358 x = x + feat[1]
359 feature = torch.mean(torch.nn.UpsamplingBilinear2d(size=(upsampleH, upsampleW))(x), dim=1)
360 feat_out.append(feature)
361 elif i == 9:
362 _, _, h, w = feat[0].shape
363 x = nn.UpsamplingBilinear2d(size=(h,w))(x)
364 x = x + feat[0]
365 feature = torch.mean(torch.nn.UpsamplingBilinear2d(size=(upsampleH, upsampleW))(x), dim=1)
366 feat_out.append(feature)
367 return feat_out, x
368
369class autoencoder_vgg7(nn.Module): # no decoder
370 ''' vgg encoder with bilinear upsampling'''

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected