From a6ac474080b5e3d97eac61063d49219897e8f196 Mon Sep 17 00:00:00 2001 From: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com> Date: Wed, 11 Feb 2026 19:34:31 +0530 Subject: [PATCH] Fix identity comparison (is not) to value comparison (!=) In `execute()`, two comparisons used `is not` instead of `!=` to compare integer values. In CPython, integers outside the cached range [-5, 256] are not guaranteed to be the same object, so `is not` can return True even when the values are equal. This causes incorrect frame count adjustment for videos with more than 256 frames, leading to silent output truncation. Replace `is not` with `!=` for correct value-based comparison. --- src/live_portrait_pipeline.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/live_portrait_pipeline.py b/src/live_portrait_pipeline.py index 2a58d403..fcedbb36 100644 --- a/src/live_portrait_pipeline.py +++ b/src/live_portrait_pipeline.py @@ -153,7 +153,7 @@ def execute(self, args: ArgumentConfig): if inf_cfg.flag_crop_driving_video or (not is_square_video(args.driving)): ret_d = self.cropper.crop_driving_video(driving_rgb_lst) log(f'Driving video is cropped, {len(ret_d["frame_crop_lst"])} frames are processed.') - if len(ret_d["frame_crop_lst"]) is not n_frames and flag_is_driving_video: + if len(ret_d["frame_crop_lst"]) != n_frames and flag_is_driving_video: n_frames = min(n_frames, len(ret_d["frame_crop_lst"])) driving_rgb_crop_lst, driving_lmk_crop_lst = ret_d['frame_crop_lst'], ret_d['lmk_crop_lst'] driving_rgb_crop_256x256_lst = [cv2.resize(_, (256, 256)) for _ in driving_rgb_crop_lst] @@ -196,7 +196,7 @@ def execute(self, args: ArgumentConfig): if inf_cfg.flag_do_crop: ret_s = self.cropper.crop_source_video(source_rgb_lst, crop_cfg) log(f'Source video is cropped, {len(ret_s["frame_crop_lst"])} frames are processed.') - if len(ret_s["frame_crop_lst"]) is not n_frames: + if len(ret_s["frame_crop_lst"]) != n_frames: n_frames = min(n_frames, len(ret_s["frame_crop_lst"])) img_crop_256x256_lst, source_lmk_crop_lst, source_M_c2o_lst = ret_s['frame_crop_lst'], ret_s['lmk_crop_lst'], ret_s['M_c2o_lst'] else: