INNER CODE UNIT · Python

border_h

Tencent-Hunyuan/HunyuanPortrait · inference.py:34

    border_h = int(h * border_ratio)
    
    # horizontal direction gradient
    if border_w > 0:
        mask[:, :border_w] = np.linspace(0, 1, border_w)[None, :]
        mask[:, -border_w:] = np.linspace(1, 0, border_w)[None, :]
    
    # vertical direction gradient
    if border_h > 0:
        mask[:border_h, :] *= np.linspace(0, 1, border_h)[:, None]
        mask[-border_h:, :] *= np.linspace(1, 0, border_h)[:, None]
        
    return mask[..., None] # add channel dimension (H, W, 1)


def paste_back_frame(original_img, generated_crop, crop_bbox, mask=None):
    """
    paste the generated cropped frame back to the original image

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…