INNER CODE UNIT · Python

border_w

Tencent-Hunyuan/HunyuanPortrait · gradio_app.py:134

    border_w = int(w * border_ratio)
    border_h = int(h * border_ratio)
    
    if border_w > 0:
        mask[:, :border_w] = np.linspace(0, 1, border_w)[None, :]
        mask[:, -border_w:] = np.linspace(1, 0, border_w)[None, :]
    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]

def paste_back_frame(original_img, generated_crop, crop_bbox, mask=None):
    """paste the generated cropped frame back to the original image"""
    x1, y1, x2, y2 = crop_bbox
    target_w = x2 - x1
    target_h = y2 - y1
    

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…