MCPcopy Create free account
hub / github.com/DragonisCV/RAM / forward

Method forward

ram/utils/img_process_util.py:74–83  ·  view source on GitHub ↗
(self, img, weight=0.5, threshold=10)

Source from the content-addressed store, hash-verified

72 self.register_buffer('kernel', kernel)
73
74 def forward(self, img, weight=0.5, threshold=10):
75 blur = filter2D(img, self.kernel)
76 residual = img - blur
77
78 mask = torch.abs(residual) * 255 > threshold
79 mask = mask.float()
80 soft_mask = filter2D(mask, self.kernel)
81 sharp = img + weight * residual
82 sharp = torch.clip(sharp, 0, 1)
83 return soft_mask * sharp + (1 - soft_mask) * img

Callers

nothing calls this directly

Calls 1

filter2DFunction · 0.85

Tested by

no test coverage detected