MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / w_smooth

Function w_smooth

utils/common.py:394–408  ·  view source on GitHub ↗
(
        depth_pred,
        depth_gt,
        threshold=0.9,
        mask=None
)

Source from the content-addressed store, hash-verified

392 return deleted
393
394def w_smooth(
395 depth_pred,
396 depth_gt,
397 threshold=0.9,
398 mask=None
399):
400 mask = torch.ones_like(depth_pred) if mask is None else mask
401
402 gx = grad_w(depth_pred)
403 # 用 GT 的边缘抑制正则(或用你生成的 edge 权重图)
404 edge = (sobel_edge_mag(depth_gt) > threshold).float()
405 w = torch.exp(-5.0 * edge) * mask # 非边缘处 w≈1,边缘处 w≈~0
406 L_smoothW = (w * gx ** 2).mean()
407
408 return L_smoothW
409
410def grad_w(img): # [B,1,H,W]
411 g = img[..., :, 1:] - img[..., :, :-1]

Callers

nothing calls this directly

Calls 2

grad_wFunction · 0.85
sobel_edge_magFunction · 0.85

Tested by

no test coverage detected