jhj0517
commited on
Commit
·
fee04a0
1
Parent(s):
57ae0de
Update frame save logic
Browse files
modules/live_portrait/live_portrait_inferencer.py
CHANGED
|
@@ -286,7 +286,6 @@ class LivePortraitInferencer:
|
|
| 286 |
c_i_es = ExpressionSet()
|
| 287 |
c_o_es = ExpressionSet()
|
| 288 |
d_0_es = None
|
| 289 |
-
out_list = []
|
| 290 |
|
| 291 |
psi = None
|
| 292 |
for i in range(total_length):
|
|
@@ -324,18 +323,11 @@ class LivePortraitInferencer:
|
|
| 324 |
cv2.INTER_LINEAR)
|
| 325 |
out = np.clip(psi.mask_ori * crop_with_fullsize + (1 - psi.mask_ori) * psi.src_rgb, 0, 255).astype(
|
| 326 |
np.uint8)
|
| 327 |
-
out_list.append(out)
|
| 328 |
-
|
| 329 |
-
progress(i/total_length, desc="Generating frames..")
|
| 330 |
|
| 331 |
-
if len(out_list) == 0:
|
| 332 |
-
return None
|
| 333 |
-
|
| 334 |
-
out_imgs = torch.cat([pil2tensor(img_rgb) for img_rgb in out_list])
|
| 335 |
-
out_imgs = [tensor.permute(1, 2, 0).cpu().numpy() for tensor in out_imgs]
|
| 336 |
-
for img in out_imgs:
|
| 337 |
out_frame_path = get_auto_incremental_file_path(TEMP_VIDEO_OUT_FRAMES_DIR, "png")
|
| 338 |
-
save_image(
|
|
|
|
|
|
|
| 339 |
|
| 340 |
video_path = create_video_from_frames(TEMP_VIDEO_OUT_FRAMES_DIR)
|
| 341 |
|
|
|
|
| 286 |
c_i_es = ExpressionSet()
|
| 287 |
c_o_es = ExpressionSet()
|
| 288 |
d_0_es = None
|
|
|
|
| 289 |
|
| 290 |
psi = None
|
| 291 |
for i in range(total_length):
|
|
|
|
| 323 |
cv2.INTER_LINEAR)
|
| 324 |
out = np.clip(psi.mask_ori * crop_with_fullsize + (1 - psi.mask_ori) * psi.src_rgb, 0, 255).astype(
|
| 325 |
np.uint8)
|
|
|
|
|
|
|
|
|
|
| 326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
out_frame_path = get_auto_incremental_file_path(TEMP_VIDEO_OUT_FRAMES_DIR, "png")
|
| 328 |
+
save_image(out, out_frame_path)
|
| 329 |
+
|
| 330 |
+
progress(i/total_length, desc=f"Generating frames {i}/{total_length} ..")
|
| 331 |
|
| 332 |
video_path = create_video_from_frames(TEMP_VIDEO_OUT_FRAMES_DIR)
|
| 333 |
|