PyTorch code to implement a gradient magnitude based edge detection loss.
Fig. Map of the magnitude of the gradients(Left-old). Map of the magnitude of the gradients with diagonal edges(Right-new/dev).
Fig. Input after 3D gaussian blur(Left). Gradient wrt x(Right)
Fig. Gradient wrt y(Left). Gradient wrt z(Right).
Fig. Magnitude of gradients(Left). Filtered magnitude of gradients.(Right).