MCPcopy
hub / github.com/nadermx/backgroundremover / forward

Method forward

backgroundremover/u2net/u2net.py:358–429  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

356 self.outconv = nn.Conv2d(6, out_ch, 1)
357
358 def forward(self, x):
359
360 hx = x
361
362 # stage 1
363 hx1 = self.stage1(hx)
364 hx = self.pool12(hx1)
365
366 # stage 2
367 hx2 = self.stage2(hx)
368 hx = self.pool23(hx2)
369
370 # stage 3
371 hx3 = self.stage3(hx)
372 hx = self.pool34(hx3)
373
374 # stage 4
375 hx4 = self.stage4(hx)
376 hx = self.pool45(hx4)
377
378 # stage 5
379 hx5 = self.stage5(hx)
380 hx = self.pool56(hx5)
381
382 # stage 6
383 hx6 = self.stage6(hx)
384 hx6up = _upsample_like(hx6, hx5)
385
386 # -------------------- decoder --------------------
387 hx5d = self.stage5d(torch.cat((hx6up, hx5), 1))
388 hx5dup = _upsample_like(hx5d, hx4)
389
390 hx4d = self.stage4d(torch.cat((hx5dup, hx4), 1))
391 hx4dup = _upsample_like(hx4d, hx3)
392
393 hx3d = self.stage3d(torch.cat((hx4dup, hx3), 1))
394 hx3dup = _upsample_like(hx3d, hx2)
395
396 hx2d = self.stage2d(torch.cat((hx3dup, hx2), 1))
397 hx2dup = _upsample_like(hx2d, hx1)
398
399 hx1d = self.stage1d(torch.cat((hx2dup, hx1), 1))
400
401 # side output
402 d1 = self.side1(hx1d)
403
404 d2 = self.side2(hx2d)
405 d2 = _upsample_like(d2, d1)
406
407 d3 = self.side3(hx3d)
408 d3 = _upsample_like(d3, d1)
409
410 d4 = self.side4(hx4d)
411 d4 = _upsample_like(d4, d1)
412
413 d5 = self.side5(hx5d)
414 d5 = _upsample_like(d5, d1)
415

Callers

nothing calls this directly

Calls 1

_upsample_likeFunction · 0.85

Tested by

no test coverage detected