Fixes Animate Replace Bug. #152
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(venv) mike@Alexandra:/project/video/Wan2.2$ python ./wan/modules/animate/preprocess/preprocess_data.py --ckpt_path ./Wan2.2-Animate-14B/process_checkpoint/ --video_path ./source/source.mp4 --refer_path ./source/person.png --save_path ./source/progress/ --resolution_area 1280 720 --iterations 3 --k 7 --w_len 1 --h_len 1 --replace_flag
{'ckpt_path': './Wan2.2-Animate-14B/process_checkpoint/', 'video_path': './source/source.mp4', 'refer_path': './source/person.png', 'save_path': './source/progress/', 'resolution_area': [1280, 720], 'fps': 30, 'replace_flag': True, 'retarget_flag': False, 'use_flux': False, 'iterations': 3, 'k': 7, 'w_len': 1, 'h_len': 1}
frame_num: 2646
video_fps: 30.0
fps: 30
target_num: 2646
2025-09-19 08:28:13.438 | INFO | process_pipepline:call:67 - Processing pose meta
2025-09-19 08:29:23.335 | INFO | process_pipepline:call:82 - Processing reference image: ./source/person.png
2025-09-19 08:29:23.352 | INFO | process_pipepline:call:89 - Processing template video: ./source/source.mp4
video frame: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 400/400 [00:07<00:00, 50.11it/s]
Traceback (most recent call last):
File "/project/video/Wan2.2/./wan/modules/animate/preprocess/preprocess_data.py", line 109, in
process_pipeline(video_path=args.video_path,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/project/video/Wan2.2/wan/modules/animate/preprocess/process_pipepline.py", line 97, in call
masks = self.get_mask(frames, 400, tpl_pose_metas)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/project/video/Wan2.2/wan/modules/animate/preprocess/process_pipepline.py", line 319, in get_mask
self.predictor.reset_state(inference_state)
File "/project/video/.venv/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/project/video/.venv/lib/python3.11/site-packages/sam2/sam2_video_predictor.py", line 678, in reset_state
self._reset_tracking_results(inference_state)
File "/project/video/.venv/lib/python3.11/site-packages/sam2/sam2_video_predictor.py", line 701, in _reset_tracking_results
for v in inference_state["frames_tracked_per_obj"].values():
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'frames_tracked_per_obj'