FangSen9000 commited on
Commit ·
2066a63
1
Parent(s): 2a1ef7e
Add verified posture setting
Browse filesFiles changed (11)
- ComfyUI-ControlNeXt-SVDAdded+1
- README.md+5-4
- generated_pose_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4 → generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708.mp4Renamed+2-2
- generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4 → generated_pose_video/HELLO_WORLD_27184_63831_20250804_215328.mp4Renamed+2-2
- generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315_combined.mp4 → generated_pose_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_215724.mp4Renamed+2-2
- generated_pose_video/NOT_FIND_YET_38868_21853_18537_20250804_220326.mp4Added+3
- generated_pose_video/NOT_FIND_YET_38868_21853_38944_20250804_223748.mp4Added+3
- generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708.mp4Added+3
- generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708_combined.mp4Added+3
- text2pose.py+145-7
- useless/abandon_cmd.md+24-5
1Subproject commit 6227d71b16602c55a159316a0f72b0b4bf281e7f15 unmodified lines1617181920212223242526163 unmodified lines19019119219319419519615 unmodified linesfirst, change `good morning afternoon`, and run:```pythonpython text2pose.py --gloss "where is my cat" --scale-y 1.4 --scale-x 1.3 --npz-interpolation 20 --width 512 --height 768 --fps 30 --hide-torso-lines falseorpython text2pose.py --gloss "good morning afternoon" --npz-interpolation 20 --width 512 --height 768 --fps 30```second, change `generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4` & `ref_img_dict/03.jpeg`, and run:163 unmodified lines--pose_video_path generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4 \--ref_image_path ref_img_dict/03.jpeg \--precision fp16 \--enable_xformers \--decode_chunk_size 2```15 unmodified lines1617181920212223242526163 unmodified lines19019119219319419519619715 unmodified linesfirst, change `good morning afternoon`, and run:```pythonpython text2pose.py --gloss "good morning afternoon" --scale-y 1.3 --scale-x 1.2 --npz-interpolation 20 --width 512 --height 768 --fps 30 --hide-torso-lines true --ref-image-path ref_img_dict/01.jpegorpython text2pose.py --gloss "where is my cat" --scale-y 1.4 --scale-x 1.3 --npz-interpolation 20 --width 512 --height 768 --fps 30 --hide-torso-lines false```second, change `generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4` & `ref_img_dict/03.jpeg`, and run:163 unmodified lines--pose_video_path generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4 \--ref_image_path ref_img_dict/03.jpeg \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \--enable_xformers```
123version https://git-lfs.github.com/spec/v1oid sha256:2c838110d6b0c453e18eb6b62aebeca205d5a1e7e32ddd35c042daa6e3ef7fedsize 2813937123version https://git-lfs.github.com/spec/v1oid sha256:e0d25a5c9af662adc2c417bbd9564cb71287f58ae6ef92cbdcc71dccd6ab6966size 1668013
123version https://git-lfs.github.com/spec/v1oid sha256:771c9a92c0901a0fc897c5a2c7142954ba7dfc02cde76834b4c8e678fa532bb9size 3010816123version https://git-lfs.github.com/spec/v1oid sha256:2ff6dbbc50441746c7d494956bc72987878f359dd5ff96c765adb51e5631becbsize 2183071
123version https://git-lfs.github.com/spec/v1oid sha256:51601f233e5df4c9888351074699c398c934f7041dafb1f18e084e315fd13e86size 3590703123version https://git-lfs.github.com/spec/v1oid sha256:ad2836123b570c7aa716e4f02e447e1e004a3d439fbcc9a6e282175475d4539csize 4409427
123version https://git-lfs.github.com/spec/v1oid sha256:912d9a76db09fe053361692239ba9644a47f144ec7832a2e38850811b9e5b652size 2095895123version https://git-lfs.github.com/spec/v1oid sha256:23b47ae5720cb5d7ba9b5e34a63e6f31f1c136d440a6a43c9113ad8a5ff5982csize 1340578123version https://git-lfs.github.com/spec/v1oid sha256:11c9bec1c44c66b4e8a914f4cf3f08bdfbc0f0ed7a476c6aa73cc8129c6df552size 1669008123version https://git-lfs.github.com/spec/v1oid sha256:9601bc572dc3c58fe6bdb055b1254c580fb7f33642e3313d81b06598a349d980size 205492931 unmodified lines323334353637171 unmodified lines209210211212213214215216217218219220221163 unmodified lines38538638738838939039139239339439539639739842 unmodified lines44144244344444544644763 unmodified lines511512513514515516517249 unmodified lines76776876977077177228 unmodified lines80180280380480580680731 unmodified linesdef __init__(self):self.gloss_data = Noneself.load_json_mapping()def load_json_mapping(self):"""Load JSON mapping file"""171 unmodified linesframe_keys = [k for k in npz_data.keys() if k.startswith('frame_') and k.endswith('_bodies')]return len(frame_keys)def create_pose_frame(self, frame_data, width=480, height=480, scale_x=1.0, scale_y=1.0, hide_torso_lines=False):"""Create single frame pose image with progressive scaling"""try:# Apply progressive scaling if neededif scale_x != 1.0 or scale_y != 1.0:frame_data = self.apply_progressive_scaling(frame_data, scale_x, scale_y)processed_pred = process_pose_data(frame_data, height, width)vis_img = draw_pose(163 unmodified linesscaled_data['faces'] = facesreturn scaled_datadef generate_video_from_glosses(self, gloss_list, output_path, fps=30, width=480, height=480,smoothing_frames=5, smoothing_method='none', npz_interpolation_frames=0,scale_x=1.0, scale_y=1.0, hide_torso_lines=False):"""Generate video from gloss list with optional progressive scaling"""# Create output directoryoutput_path.parent.mkdir(parents=True, exist_ok=True)# Collect all frames from all glossesall_pose_frames = []all_npz_data = [] # Store NPZ data for interpolation42 unmodified linesfor frame_num in range(start_frame, end_frame + 1):frame_data = self.get_frame_data(npz_data, frame_num)if frame_data and self.check_frame_quality(frame_data):pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines)if pose_frame is not None:gloss_frames.append(pose_frame)63 unmodified lines# Create visual frameif frame_data:pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines)if pose_frame is not None:interpolated_pose_frames.append(pose_frame)249 unmodified lineshelp='Progressive Y-axis scaling factor (default: 1.0)')parser.add_argument('--hide-torso-lines', type=str, choices=['true', 'false'], default='false',help='Hide torso lines from neck to hips (set to black). Choices: true/false (default: false)')args = parser.parse_args()28 unmodified linessuccess = qa_system.generate_video_from_glosses(gloss_list, output_file, args.fps, args.width, args.height,args.smoothing_frames, args.smoothing, args.npz_interpolation,args.scale_x, args.scale_y, args.hide_torso_lines == 'true')if not success:31 unmodified lines32333435363738171 unmodified lines210211212213214215216217218219220221222223224225226163 unmodified lines39039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452542 unmodified lines56856957057157257357457557657757857958058158263 unmodified lines646647648649650651652249 unmodified lines90290390490590690790890928 unmodified lines93893994094194294394494531 unmodified linesdef __init__(self):self.gloss_data = Noneself.load_json_mapping()self.detector = None # Lazy load DWpose detector when neededdef load_json_mapping(self):"""Load JSON mapping file"""171 unmodified linesframe_keys = [k for k in npz_data.keys() if k.startswith('frame_') and k.endswith('_bodies')]return len(frame_keys)def create_pose_frame(self, frame_data, width=480, height=480, scale_x=1.0, scale_y=1.0, hide_torso_lines=False, y_offset=0):"""Create single frame pose image with progressive scaling and optional y offset"""try:# Apply progressive scaling if neededif scale_x != 1.0 or scale_y != 1.0:frame_data = self.apply_progressive_scaling(frame_data, scale_x, scale_y)# Apply y offset if providedif y_offset != 0:frame_data = self.apply_y_offset(frame_data, y_offset)processed_pred = process_pose_data(frame_data, height, width)vis_img = draw_pose(163 unmodified linesscaled_data['faces'] = facesreturn scaled_datadef apply_y_offset(self, frame_data, y_offset):"""Apply vertical offset to all pose points"""offset_data = copy.deepcopy(frame_data)# Apply offset to bodiesif 'bodies' in offset_data and offset_data['bodies'] is not None:offset_data['bodies'][:, 1] += y_offset# Apply offset to handsif 'hands' in offset_data and offset_data['hands'] is not None:if len(offset_data['hands'].shape) == 3:offset_data['hands'][:, :, 1] += y_offsetelse:offset_data['hands'][:, 1] += y_offset# Apply offset to facesif 'faces' in offset_data and offset_data['faces'] is not None:if len(offset_data['faces'].shape) == 3:offset_data['faces'][:, :, 1] += y_offsetelse:offset_data['faces'][:, 1] += y_offsetreturn offset_datadef get_reference_head_top(self, ref_image_path, width, height):"""Get the top of head position from reference image"""try:# Lazy load detectorif self.detector is None:device = "cuda:0" if torch.cuda.is_available() else "cpu"self.detector = DWposeDetector(device=device)# Load and detect pose in reference imageref_image = Image.open(ref_image_path).convert("RGB")# Resize reference image to match target dimensionsref_image = ref_image.resize((width, height), Image.LANCZOS)# Detect posepose_data = self.detector(ref_image, draw_pose=False)# Find head top from face pointsif 'faces' in pose_data and pose_data['faces'] is not None and len(pose_data['faces']) > 0:faces = pose_data['faces']if len(faces.shape) == 3:# Multiple faces, use first oneface_points = faces[0]else:face_points = faces# Get all valid Y coordinatesy_coords = face_points[:, 1]valid_y = y_coords[y_coords > 0]if len(valid_y) > 0:# Head top is the minimum Y coordinate (top of the image)head_top_y = np.min(valid_y)return head_top_y# If no face found, try to use body pointsif 'bodies' in pose_data and pose_data['bodies'] is not None:bodies = pose_data['bodies']# Look for head-related points (eyes, ears, nose)# Indices 0=nose, 14=right eye, 15=left eye, 16=right ear, 17=left earhead_indices = [0, 14, 15, 16, 17]head_y_coords = []for idx in head_indices:if idx < len(bodies) and bodies[idx, 1] > 0:head_y_coords.append(bodies[idx, 1])if head_y_coords:return min(head_y_coords)return Noneexcept Exception as e:print(f"⚠️ Failed to get reference head position: {e}")return Nonedef get_pose_head_top(self, frame_data):"""Get the top of head position from pose frame data"""# Try faces firstif 'faces' in frame_data and frame_data['faces'] is not None:faces = frame_data['faces']if len(faces.shape) == 3:# Multiple faces, use first oneface_points = faces[0]else:face_points = faces# Get all valid Y coordinatesy_coords = face_points[:, 1]valid_y = y_coords[y_coords > 0]if len(valid_y) > 0:return np.min(valid_y)# Fall back to body pointsif 'bodies' in frame_data and frame_data['bodies'] is not None:bodies = frame_data['bodies']# Look for head-related pointshead_indices = [0, 14, 15, 16, 17] # nose, eyes, earshead_y_coords = []for idx in head_indices:if idx < len(bodies) and bodies[idx, 1] > 0:head_y_coords.append(bodies[idx, 1])if head_y_coords:return min(head_y_coords)return Nonedef generate_video_from_glosses(self, gloss_list, output_path, fps=30, width=480, height=480,smoothing_frames=5, smoothing_method='none', npz_interpolation_frames=0,scale_x=1.0, scale_y=1.0, hide_torso_lines=False, ref_image_path=None):"""Generate video from gloss list with optional progressive scaling and head alignment"""# Create output directoryoutput_path.parent.mkdir(parents=True, exist_ok=True)# Get reference head position if providedref_head_top = Noney_offset = 0if ref_image_path:ref_head_top = self.get_reference_head_top(ref_image_path, width, height)if ref_head_top is not None:print(f"📏 Reference head top position: {ref_head_top:.2f}")# Collect all frames from all glossesall_pose_frames = []all_npz_data = [] # Store NPZ data for interpolation42 unmodified linesfor frame_num in range(start_frame, end_frame + 1):frame_data = self.get_frame_data(npz_data, frame_num)if frame_data and self.check_frame_quality(frame_data):# Calculate y offset for first frame if reference providedif ref_head_top is not None and y_offset == 0 and frame_num == start_frame:# Get head top from current posecurrent_head_top = self.get_pose_head_top(frame_data)if current_head_top is not None:y_offset = ref_head_top - current_head_topprint(f"📐 Calculated Y offset: {y_offset:.2f}")pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines, y_offset)if pose_frame is not None:gloss_frames.append(pose_frame)63 unmodified lines# Create visual frameif frame_data:pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines, y_offset)if pose_frame is not None:interpolated_pose_frames.append(pose_frame)249 unmodified lineshelp='Progressive Y-axis scaling factor (default: 1.0)')parser.add_argument('--hide-torso-lines', type=str, choices=['true', 'false'], default='false',help='Hide torso lines from neck to hips (set to black). Choices: true/false (default: false)')parser.add_argument('--ref-image-path', type=str, default=None,help='Reference image path for head alignment')args = parser.parse_args()28 unmodified linessuccess = qa_system.generate_video_from_glosses(gloss_list, output_file, args.fps, args.width, args.height,args.smoothing_frames, args.smoothing, args.npz_interpolation,args.scale_x, args.scale_y, args.hide_torso_lines == 'true',args.ref_image_path)if not success:
9 unmodified lines101112131415161718192021226 unmodified lines293031323334353612 unmodified lines4950515253545511 unmodified lines676869707172739 unmodified lines--width 512 \--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/HELLO_WORLD_27184_63831_20250804_163910.mp4 \--ref_image_path ref_img_dict/01.jpeg \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \--enable_xformersCUDA_VISIBLE_DEVICES=1 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \--output_dir generated_sign_video \6 unmodified lines--width 512 \--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_164010.mp4 \--ref_image_path ref_img_dict/02.jpeg \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \12 unmodified lines--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/NOT_FIND_YET_38868_21853_18535_20250804_164149.mp4 \--ref_image_path ref_img_dict/dsgs_ref.jpg \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \11 unmodified lines--width 512 \--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4 \--ref_image_path ref_img_dict/lis_ref.jpg \--precision fp16 \--decode_chunk_size 2 \9 unmodified lines10111213141516171819202122232425262728293031323334353637383940416 unmodified lines484950515253545512 unmodified lines6869707172737411 unmodified lines868788899091929 unmodified lines--width 512 \--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708.mp4 \--ref_image_path ref_img_dict/01.jpeg \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \--enable_xformersCUDA_VISIBLE_DEVICES=0 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \--output_dir generated_sign_video \--max_frame_num 240 \--guidance_scale 3 \--batch_frames 24 \--sample_stride 2 \--overlap 4 \--height 768 \--width 512 \--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/HELLO_WORLD_27184_63831_20250804_215328.mp4 \--ref_image_path ref_img_dict/04.jpeg \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \--enable_xformersCUDA_VISIBLE_DEVICES=1 python ControlNeXt-SVD-v2/run_controlnext_optimized.py \--pretrained_model_name_or_path stabilityai/stable-video-diffusion-img2vid-xt-1-1 \--output_dir generated_sign_video \6 unmodified lines--width 512 \--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/code/StableSigner3/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_215724.mp4 \--ref_image_path ref_img_dict/03.jpeg \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \12 unmodified lines--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/NOT_FIND_YET_38868_21853_18535_20250804_164149.mp4 \--ref_image_path ref_img_dict/asl_ref_v.png \--precision fp16 \--decode_chunk_size 2 \--enable_geglu_optimization \11 unmodified lines--width 512 \--controlnext_path ControlNeXt-SVD-v2/pretrained/controlnet.bin \--unet_path ControlNeXt-SVD-v2/pretrained/unet.bin \--pose_video_path generated_pose_video/WHERE_IS_MY_CAT_63084_66583_37469_65313_20250804_205149.mp4 \--ref_image_path ref_img_dict/lis_ref.jpg \--precision fp16 \--decode_chunk_size 2 \
ComfyUI-ControlNeXt-SVDAdded+1
README.md+5-4
generated_pose_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4 → generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708.mp4Renamed+2-2
generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315.mp4 → generated_pose_video/HELLO_WORLD_27184_63831_20250804_215328.mp4Renamed+2-2
generated_sign_video/WHERE_IS_MY_CAT_63084_44900_37469_65313_20250804_195315_combined.mp4 → generated_pose_video/I_WILL_ATTEND_THIS_DINNER_PARTY_28794_63364_04007_66628_16327_41325_20250804_215724.mp4Renamed+2-2
generated_pose_video/NOT_FIND_YET_38868_21853_18537_20250804_220326.mp4Added+3
generated_pose_video/NOT_FIND_YET_38868_21853_38944_20250804_223748.mp4Added+3
generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708.mp4Added+3
generated_sign_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_214708_combined.mp4Added+3
text2pose.py+145-7
useless/abandon_cmd.md+24-5