INNER CODE UNIT · Python
video
Tencent-Hunyuan/HunyuanPortrait · gradio_app.py:336
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))
print(f"Saving videos to {job_dir} with FPS {fps}")
save_videos_grid(video, save_video_path_crop, n_rows=1, fps=fps)