INNER CODE UNIT · Python

target_h

Tencent-Hunyuan/HunyuanPortrait · gradio_app.py:150

    target_h = y2 - y1
    
    generated_resized = cv2.resize(generated_crop, (target_w, target_h))
    
    if mask is None:
        mask = create_soft_mask((target_w, target_h))
        
    background_region = original_img[y1:y2, x1:x2].astype(np.float32) / 255.0
    foreground_region = generated_resized.astype(np.float32) / 255.0
    
    blended_region = foreground_region * mask + background_region * (1 - mask)
    
    result_img = original_img.copy()
    result_img[y1:y2, x1:x2] = (blended_region * 255).astype(np.uint8)
    
    return result_img

# --- 3. Inference Function ---

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…