INNER CODE UNIT · Python

video

Tencent-Hunyuan/HunyuanPortrait · gradio_app.py:334

    video = (video*0.5 + 0.5).clamp(0, 1).cpu()
    if cfg.pad_frames > 0:
        video = video[:, :, cfg.pad_frames:-cfg.pad_frames]

    # Post-processing & Paste Back
    print("Processing Paste Back...")
    generated_frames = video[0].permute(1, 2, 3, 0).numpy() # (T, H, W, C)
    generated_frames = (generated_frames * 255).astype(np.uint8)
    
    final_frames = []
    x1, y1, x2, y2 = crop_bbox
    soft_mask = create_soft_mask((x2 - x1, y2 - y1))
    
    for i in range(len(generated_frames)):
        gen_frame = generated_frames[i]
        full_frame = paste_back_frame(original_image, gen_frame, crop_bbox, soft_mask)
        final_frames.append(Image.fromarray(full_frame))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…