INNER CODE UNIT · Python

depth_image

Boese0601/MagicDance · model_lib/ControlNet/annotator/midas/__init__.py:24

        depth_image = (depth_pt * 255.0).clip(0, 255).astype(np.uint8)

        depth_np = depth.cpu().numpy()
        x = cv2.Sobel(depth_np, cv2.CV_32F, 1, 0, ksize=3)
        y = cv2.Sobel(depth_np, cv2.CV_32F, 0, 1, ksize=3)
        z = np.ones_like(x) * a
        x[depth_pt < bg_th] = 0
        y[depth_pt < bg_th] = 0
        normal = np.stack([x, y, z], axis=2)
        normal /= np.sum(normal ** 2.0, axis=2, keepdims=True) ** 0.5
        normal_image = (normal * 127.5 + 127.5).clip(0, 255).astype(np.uint8)

        return depth_image, normal_image

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…