MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / grad

Function grad

dzoedepth/trainers/loss.py:96–103  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

94
95
96def grad(x):
97 # x.shape : n, c, h, w
98 diff_x = x[..., 1:, 1:] - x[..., 1:, :-1]
99 diff_y = x[..., 1:, 1:] - x[..., :-1, 1:]
100 mag = diff_x**2 + diff_y**2
101 # angle_ratio
102 angle = torch.atan(diff_y / (diff_x + 1e-10))
103 return mag, angle
104
105
106def grad_mask(mask):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected