INNER CODE UNIT · Python

apply_hed

Boese0601/MagicDance · model_lib/ControlNet/annotator/hed/__init__.py:100

def apply_hed(input_image):
    assert input_image.ndim == 3
    input_image = input_image[:, :, ::-1].copy()
    with torch.no_grad():
        image_hed = torch.from_numpy(input_image).float().cuda()
        image_hed = image_hed / 255.0
        image_hed = rearrange(image_hed, 'h w c -> 1 c h w')
        edge = netNetwork(image_hed)[0]
        edge = (edge.cpu().numpy() * 255.0).clip(0, 255).astype(np.uint8)
        return edge[0]


def nms(x, t, s):
    x = cv2.GaussianBlur(x.astype(np.float32), (0, 0), s)

    f1 = np.array([[0, 0, 0], [1, 1, 1], [0, 0, 0]], dtype=np.uint8)
    f2 = np.array([[0, 1, 0], [0, 1, 0], [0, 1, 0]], dtype=np.uint8)
    f3 = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=np.uint8)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…