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 lines16171819192021222323242526163 unmodified lines19019119219319419319419519619715 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 falsepython 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.jpeg
or
python text2pose.py --gloss "good morning afternoon" --npz-interpolation 20 --width 512 --height 768 --fps 30python 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 \ --enable_xformers \ --decode_chunk_size 2 --decode_chunk_size 2 \ --enable_geglu_optimization \ --enable_xformers ```
12323version https://git-lfs.github.com/spec/v1oid sha256:2c838110d6b0c453e18eb6b62aebeca205d5a1e7e32ddd35c042daa6e3ef7fedsize 2813937oid sha256:e0d25a5c9af662adc2c417bbd9564cb71287f58ae6ef92cbdcc71dccd6ab6966size 166801312323version https://git-lfs.github.com/spec/v1oid sha256:771c9a92c0901a0fc897c5a2c7142954ba7dfc02cde76834b4c8e678fa532bb9size 3010816oid sha256:2ff6dbbc50441746c7d494956bc72987878f359dd5ff96c765adb51e5631becbsize 218307112323version https://git-lfs.github.com/spec/v1oid sha256:51601f233e5df4c9888351074699c398c934f7041dafb1f18e084e315fd13e86size 3590703oid sha256:ad2836123b570c7aa716e4f02e447e1e004a3d439fbcc9a6e282175475d4539csize 4409427123version 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 lines32333435363738171 unmodified lines210211212212213213214215216217218219220221222223224225226163 unmodified lines39039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850939139251051151251351451551651751851952052152252352452542 unmodified lines56856957057157257357457557657757844457958058158263 unmodified lines646647648514649650651652249 unmodified lines90290390490590690790890928 unmodified lines93893994080494194294394494531 unmodified lines def __init__(self): self.gloss_data = None self.load_json_mapping() self.detector = None # Lazy load DWpose detector when needed
def load_json_mapping(self): """Load JSON mapping file"""171 unmodified lines frame_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""" 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 needed if 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 provided if 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 lines scaled_data['faces'] = faces return scaled_data def apply_y_offset(self, frame_data, y_offset): """Apply vertical offset to all pose points""" offset_data = copy.deepcopy(frame_data) # Apply offset to bodies if 'bodies' in offset_data and offset_data['bodies'] is not None: offset_data['bodies'][:, 1] += y_offset # Apply offset to hands if 'hands' in offset_data and offset_data['hands'] is not None: if len(offset_data['hands'].shape) == 3: offset_data['hands'][:, :, 1] += y_offset else: offset_data['hands'][:, 1] += y_offset # Apply offset to faces if 'faces' in offset_data and offset_data['faces'] is not None: if len(offset_data['faces'].shape) == 3: offset_data['faces'][:, :, 1] += y_offset else: offset_data['faces'][:, 1] += y_offset return offset_data def get_reference_head_top(self, ref_image_path, width, height): """Get the top of head position from reference image""" try: # Lazy load detector if 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 image ref_image = Image.open(ref_image_path).convert("RGB") # Resize reference image to match target dimensions ref_image = ref_image.resize((width, height), Image.LANCZOS) # Detect pose pose_data = self.detector(ref_image, draw_pose=False) # Find head top from face points if '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 one face_points = faces[0] else: face_points = faces # Get all valid Y coordinates y_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 points if '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 ear head_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 None except Exception as e: print(f"⚠️ Failed to get reference head position: {e}") return None def get_pose_head_top(self, frame_data): """Get the top of head position from pose frame data""" # Try faces first if 'faces' in frame_data and frame_data['faces'] is not None: faces = frame_data['faces'] if len(faces.shape) == 3: # Multiple faces, use first one face_points = faces[0] else: face_points = faces # Get all valid Y coordinates y_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 points if 'bodies' in frame_data and frame_data['bodies'] is not None: bodies = frame_data['bodies'] # Look for head-related points head_indices = [0, 14, 15, 16, 17] # nose, eyes, ears 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 None
def 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""" 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 directory output_path.parent.mkdir(parents=True, exist_ok=True) # Get reference head position if provided ref_head_top = None y_offset = 0 if 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 glosses all_pose_frames = [] all_npz_data = [] # Store NPZ data for interpolation42 unmodified lines for 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 provided if ref_head_top is not None and y_offset == 0 and frame_num == start_frame: # Get head top from current pose current_head_top = self.get_pose_head_top(frame_data) if current_head_top is not None: y_offset = ref_head_top - current_head_top print(f"📐 Calculated Y offset: {y_offset:.2f}") pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines) 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 frame if frame_data: pose_frame = self.create_pose_frame(frame_data, width, height, scale_x, scale_y, hide_torso_lines) 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 lines help='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 lines success = 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.scale_x, args.scale_y, args.hide_torso_lines == 'true', args.ref_image_path )
if not success:9 unmodified lines1011121313141516171819202122232425262728293031323334353637383940416 unmodified lines4849503233515253545512 unmodified lines686970527172737411 unmodified lines86878870899091929 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 \ --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_xformers
CUDA_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_xformers
CUDA_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 \ --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/dsgs_ref.jpg \ --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_44900_37469_65313_20250804_195315.mp4 \ --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