FangSen9000 Claude commited on
Commit ·
ac71c07
1
Parent(s): b0cc904
Refactor to use individual NPZ files instead of merged database
Browse filesMajor changes:
- Replace merged database approach with individual NPZ files per video
- Add WLASL_train.json mapping file and 9575 individual NPZ files in pose_dict/
- Create new text2pose_individual.py for working with individual NPZ files
- Add generated_pose_video/ directory for output videos
- Remove old pipeline scripts that worked with merged database
- Update file structure to be more modular and efficient
Benefits:
- More flexible video selection
- Easier to add/remove individual videos
- Better memory efficiency (load only needed videos)
- Cleaner file organization
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This view is limited to 50 files because it contains too many changes. See raw diff
- README.md +37 -0
- easy_dwpose/__pycache__/__init__.cpython-312.pyc +0 -0
- easy_dwpose/__pycache__/dwpose.cpython-312.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/__init__.cpython-312.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/detector.cpython-312.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/pose.cpython-312.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/utils.cpython-312.pyc +0 -0
- easy_dwpose/body_estimation/__pycache__/wholebody.cpython-312.pyc +0 -0
- easy_dwpose/draw/__pycache__/__init__.cpython-312.pyc +0 -0
- easy_dwpose/draw/__pycache__/controlnext.cpython-312.pyc +0 -0
- easy_dwpose/draw/__pycache__/openpose.cpython-312.pyc +0 -0
- generated_pose_video/HELLO_27184_20250803_164908.mp4 +3 -0
- generated_pose_video/HELLO_WORLD_27184_63831_20250803_165003_fade.mp4 +3 -0
- pipeline/{pipeline02_merge_npz.py → pipeline01_merge_frame_level_npz_from_video_dir.py} +147 -58
- pose_dict/WLASL_train.json +0 -0
- pose_dict/WLASL_train/00335.npz +3 -0
- pose_dict/WLASL_train/00339.npz +3 -0
- pose_dict/WLASL_train/00376.npz +3 -0
- pose_dict/WLASL_train/00381.npz +3 -0
- pose_dict/WLASL_train/00382.npz +3 -0
- pose_dict/WLASL_train/00414.npz +3 -0
- pose_dict/WLASL_train/00415.npz +3 -0
- pose_dict/WLASL_train/00421.npz +3 -0
- pose_dict/WLASL_train/00426.npz +3 -0
- pose_dict/WLASL_train/00430.npz +3 -0
- pose_dict/WLASL_train/00431.npz +3 -0
- pose_dict/WLASL_train/00435.npz +3 -0
- pose_dict/WLASL_train/00583.npz +3 -0
- pose_dict/WLASL_train/00584.npz +3 -0
- pose_dict/WLASL_train/00586.npz +3 -0
- pose_dict/WLASL_train/00592.npz +3 -0
- pose_dict/WLASL_train/00593.npz +3 -0
- pose_dict/WLASL_train/00597.npz +3 -0
- pose_dict/WLASL_train/00600.npz +3 -0
- pose_dict/WLASL_train/00603.npz +3 -0
- pose_dict/WLASL_train/00626.npz +3 -0
- pose_dict/WLASL_train/00627.npz +3 -0
- pose_dict/WLASL_train/00628.npz +3 -0
- pose_dict/WLASL_train/00629.npz +3 -0
- pose_dict/WLASL_train/00631.npz +3 -0
- pose_dict/WLASL_train/00633.npz +3 -0
- pose_dict/WLASL_train/00634.npz +3 -0
- pose_dict/WLASL_train/00663.npz +3 -0
- pose_dict/WLASL_train/00664.npz +3 -0
- pose_dict/WLASL_train/00666.npz +3 -0
- pose_dict/WLASL_train/00668.npz +3 -0
- pose_dict/WLASL_train/00689.npz +3 -0
- pose_dict/WLASL_train/00690.npz +3 -0
- pose_dict/WLASL_train/00692.npz +3 -0
- pose_dict/WLASL_train/00832.npz +3 -0
README.md
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# For developers
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
## tutorial00 Use DWpose to preprocess the original sign language video
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
## tutorial01 prepare pose dict
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
## tutorial02 get pose video from text input
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
## tutorial03 render pose video
|
| 10 |
|
| 11 |
|
|
|
|
| 1 |
+
# Intro
|
| 2 |
+
|
| 3 |
+
The entire project is divided into two parts: `text_or_gloss2pose` and `pose2video`. "Pose" here refers to the skeleton pose video after drawing.
|
| 4 |
+
|
| 5 |
+
- In the text2pose section, I first used the DWpose tool to extract the npz format pose information for each word video frame by frame, and then merged each frame's npz into a large npz file. That is to say, we know the consecutive poses corresponding to each word. These consecutive poses are stored in the merged npz file. (We can also use deep learning models to generate these poses, but for commercial-level accuracy, this original data Dict method will be much more accurate.)
|
| 6 |
+
|
| 7 |
+
- In the pose2video section, we render the visualized poses of the skeletons generated by each word. I used the ControlNext-SVD model for this.
|
| 8 |
+
|
| 9 |
# For developers
|
| 10 |
|
| 11 |
+
1. git clone https://huggingface.co/datasets/FangSen9000/StableSigner
|
| 12 |
+
2. cd StableSigner
|
| 13 |
+
|
| 14 |
## tutorial00 Use DWpose to preprocess the original sign language video
|
| 15 |
|
| 16 |
+
`tools-new-2025` is a tool that can extract the original video into a npz file containing dwpose skeleton posture information (a type of skeleton posture that is almost compatible with all current pose2video models).
|
| 17 |
+
|
| 18 |
+
1. conda env create -f env/environment01_dwpose.yml
|
| 19 |
+
2. run `conda activate dwpose`
|
| 20 |
+
3. run `pip install env/requirements01_dwpose.txt`
|
| 21 |
+
4. put raw sign viseos, like `tools-new-2025/input/test_dataset`
|
| 22 |
+
5. cd `StableSigner3/tools-new-2025/main`
|
| 23 |
+
6. run `python pipeline00_extract_split_video_to_image.py` (Default frame rate is 30fps, and the video will be automatically cropped to a square shape.)
|
| 24 |
+
7. run `python pipeline01_extract_dwpose_from_video.py` (It will generate files other than npz. We usually don't need them and can comment out the relevant code.)
|
| 25 |
+
8. run `conda deactivate`, we finish the preprocess.
|
| 26 |
+
|
| 27 |
## tutorial01 prepare pose dict
|
| 28 |
|
| 29 |
+
1. cd StableSigner
|
| 30 |
+
2. run `python pipeline/pipeline01_merge_frame_level_npz_from_video_dir.py tools-new-2025/output/test_dataset_results`
|
| 31 |
+
3. Place the corresponding "gloss-videoID" mapping in the pose dict
|
| 32 |
+
|
| 33 |
## tutorial02 get pose video from text input
|
| 34 |
|
| 35 |
+
```python
|
| 36 |
+
# Single gloss
|
| 37 |
+
python text2pose.py --gloss "hello"
|
| 38 |
+
|
| 39 |
+
# Multiple glosses with smoothing
|
| 40 |
+
python text2pose.py --gloss "hello world" --smoothing fade --smoothing-frames 5
|
| 41 |
+
|
| 42 |
+
# Custom video parameters
|
| 43 |
+
python text2pose.py --gloss "afternoon" --width 640 --height 480 --fps 25
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
## tutorial03 render pose video
|
| 47 |
|
| 48 |
|
easy_dwpose/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (253 Bytes). View file
|
|
|
easy_dwpose/__pycache__/dwpose.cpython-312.pyc
ADDED
|
Binary file (4.47 kB). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (307 Bytes). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/detector.cpython-312.pyc
ADDED
|
Binary file (8.05 kB). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/pose.cpython-312.pyc
ADDED
|
Binary file (15.9 kB). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/utils.cpython-312.pyc
ADDED
|
Binary file (1.23 kB). View file
|
|
|
easy_dwpose/body_estimation/__pycache__/wholebody.cpython-312.pyc
ADDED
|
Binary file (2.74 kB). View file
|
|
|
easy_dwpose/draw/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (258 Bytes). View file
|
|
|
easy_dwpose/draw/__pycache__/controlnext.cpython-312.pyc
ADDED
|
Binary file (12 kB). View file
|
|
|
easy_dwpose/draw/__pycache__/openpose.cpython-312.pyc
ADDED
|
Binary file (6.57 kB). View file
|
|
|
generated_pose_video/HELLO_27184_20250803_164908.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6351055b804acc5473154d575f65eab0946de032a266eb765a92312b8c0e8f12
|
| 3 |
+
size 561551
|
generated_pose_video/HELLO_WORLD_27184_63831_20250803_165003_fade.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94919506b7131e8313c931608196190092d523574f8858d77abaf384509e6717
|
| 3 |
+
size 1667961
|
pipeline/{pipeline02_merge_npz.py → pipeline01_merge_frame_level_npz_from_video_dir.py}
RENAMED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
NPZ
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
"""
|
| 10 |
|
| 11 |
import os
|
|
@@ -16,19 +17,19 @@ import argparse
|
|
| 16 |
from collections import defaultdict
|
| 17 |
|
| 18 |
def extract_frame_number(filename):
|
| 19 |
-
"""
|
| 20 |
-
#
|
| 21 |
name = Path(filename).stem
|
| 22 |
try:
|
| 23 |
return int(name)
|
| 24 |
except ValueError:
|
| 25 |
-
print(f"
|
| 26 |
return 0
|
| 27 |
|
| 28 |
def get_video_name_from_path(npz_folder_path):
|
| 29 |
-
"""
|
| 30 |
-
#
|
| 31 |
-
#
|
| 32 |
path_parts = Path(npz_folder_path).parts
|
| 33 |
for part in reversed(path_parts):
|
| 34 |
if part != 'npz' and part != 'results_dwpose':
|
|
@@ -37,70 +38,70 @@ def get_video_name_from_path(npz_folder_path):
|
|
| 37 |
|
| 38 |
def merge_npz_files(npz_folder_path, output_folder="./posedict"):
|
| 39 |
"""
|
| 40 |
-
|
| 41 |
|
| 42 |
Args:
|
| 43 |
-
npz_folder_path:
|
| 44 |
-
output_folder:
|
| 45 |
"""
|
| 46 |
|
| 47 |
-
#
|
| 48 |
npz_folder = Path(npz_folder_path)
|
| 49 |
if not npz_folder.exists():
|
| 50 |
-
print(f"
|
| 51 |
return False
|
| 52 |
|
| 53 |
-
#
|
| 54 |
npz_files = list(npz_folder.glob("*.npz"))
|
| 55 |
if not npz_files:
|
| 56 |
-
print(f"
|
| 57 |
return False
|
| 58 |
|
| 59 |
-
print(f"
|
| 60 |
|
| 61 |
-
#
|
| 62 |
npz_files.sort(key=lambda x: extract_frame_number(x.name))
|
| 63 |
|
| 64 |
-
#
|
| 65 |
output_path = Path(output_folder)
|
| 66 |
output_path.mkdir(parents=True, exist_ok=True)
|
| 67 |
|
| 68 |
-
#
|
| 69 |
video_name = get_video_name_from_path(npz_folder_path)
|
| 70 |
output_file = output_path / f"{video_name}.npz"
|
| 71 |
|
| 72 |
-
#
|
| 73 |
merged_data = {}
|
| 74 |
|
| 75 |
for npz_file in npz_files:
|
| 76 |
frame_number = extract_frame_number(npz_file.name)
|
| 77 |
-
frame_key = f"frame_{frame_number:08d}" #
|
| 78 |
|
| 79 |
try:
|
| 80 |
-
#
|
| 81 |
data = np.load(npz_file, allow_pickle=True)
|
| 82 |
|
| 83 |
-
#
|
| 84 |
frame_data = {}
|
| 85 |
for key in data.files:
|
| 86 |
frame_data[key] = data[key]
|
| 87 |
|
| 88 |
merged_data[frame_key] = frame_data
|
| 89 |
|
| 90 |
-
print(f"
|
| 91 |
|
| 92 |
except Exception as e:
|
| 93 |
-
print(f"
|
| 94 |
continue
|
| 95 |
|
| 96 |
if not merged_data:
|
| 97 |
-
print("
|
| 98 |
return False
|
| 99 |
|
| 100 |
-
#
|
| 101 |
try:
|
| 102 |
-
#
|
| 103 |
-
#
|
| 104 |
flattened_data = {}
|
| 105 |
|
| 106 |
for frame_key, frame_data in merged_data.items():
|
|
@@ -108,7 +109,7 @@ def merge_npz_files(npz_folder_path, output_folder="./posedict"):
|
|
| 108 |
combined_key = f"{frame_key}_{data_key}"
|
| 109 |
flattened_data[combined_key] = data_value
|
| 110 |
|
| 111 |
-
#
|
| 112 |
frame_info = {
|
| 113 |
'frame_count': len(merged_data),
|
| 114 |
'frame_keys': list(merged_data.keys()),
|
|
@@ -120,30 +121,30 @@ def merge_npz_files(npz_folder_path, output_folder="./posedict"):
|
|
| 120 |
|
| 121 |
np.savez_compressed(output_file, **flattened_data)
|
| 122 |
|
| 123 |
-
print(f"\
|
| 124 |
-
print(f"
|
| 125 |
-
print(f"
|
| 126 |
|
| 127 |
return True
|
| 128 |
|
| 129 |
except Exception as e:
|
| 130 |
-
print(f"
|
| 131 |
return False
|
| 132 |
|
| 133 |
def load_merged_npz(npz_file_path):
|
| 134 |
"""
|
| 135 |
-
|
| 136 |
|
| 137 |
Args:
|
| 138 |
-
npz_file_path:
|
| 139 |
|
| 140 |
Returns:
|
| 141 |
-
dict:
|
| 142 |
"""
|
| 143 |
data = np.load(npz_file_path, allow_pickle=True)
|
| 144 |
metadata = data['_metadata'].item()
|
| 145 |
|
| 146 |
-
#
|
| 147 |
frames_data = {}
|
| 148 |
original_keys = metadata['original_keys']
|
| 149 |
|
|
@@ -157,30 +158,118 @@ def load_merged_npz(npz_file_path):
|
|
| 157 |
|
| 158 |
return frames_data, metadata
|
| 159 |
|
| 160 |
-
def
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
-
#
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
else:
|
| 182 |
-
|
| 183 |
-
|
|
|
|
|
|
|
| 184 |
|
| 185 |
if __name__ == "__main__":
|
| 186 |
main()
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
NPZ File Merging Script
|
| 4 |
+
Usage:
|
| 5 |
+
Dataset mode: python merge.py /path/to/WLASL_train_results
|
| 6 |
+
Single mode: python merge.py /path/to/video/npz --single
|
| 7 |
|
| 8 |
+
In dataset mode, automatically processes all videos and saves to ./pose_dict/dataset_name/
|
| 9 |
+
In single mode, merges one video's npz files and saves to ./posedict/
|
| 10 |
"""
|
| 11 |
|
| 12 |
import os
|
|
|
|
| 17 |
from collections import defaultdict
|
| 18 |
|
| 19 |
def extract_frame_number(filename):
|
| 20 |
+
"""Extract frame number from filename"""
|
| 21 |
+
# Assumes filename format: 00000001.npz, 00000002.npz, etc.
|
| 22 |
name = Path(filename).stem
|
| 23 |
try:
|
| 24 |
return int(name)
|
| 25 |
except ValueError:
|
| 26 |
+
print(f"Warning: Unable to extract frame number from filename '{filename}'")
|
| 27 |
return 0
|
| 28 |
|
| 29 |
def get_video_name_from_path(npz_folder_path):
|
| 30 |
+
"""Extract video name from path"""
|
| 31 |
+
# Path format: ./assets/WLASL_01214/results_dwpose/npz
|
| 32 |
+
# Extract WLASL_01214 as video name
|
| 33 |
path_parts = Path(npz_folder_path).parts
|
| 34 |
for part in reversed(path_parts):
|
| 35 |
if part != 'npz' and part != 'results_dwpose':
|
|
|
|
| 38 |
|
| 39 |
def merge_npz_files(npz_folder_path, output_folder="./posedict"):
|
| 40 |
"""
|
| 41 |
+
Merge all npz files in the specified folder
|
| 42 |
|
| 43 |
Args:
|
| 44 |
+
npz_folder_path: Path to folder containing npz files
|
| 45 |
+
output_folder: Output folder path
|
| 46 |
"""
|
| 47 |
|
| 48 |
+
# Ensure input path exists
|
| 49 |
npz_folder = Path(npz_folder_path)
|
| 50 |
if not npz_folder.exists():
|
| 51 |
+
print(f"Error: Folder '{npz_folder_path}' does not exist")
|
| 52 |
return False
|
| 53 |
|
| 54 |
+
# Get all npz files
|
| 55 |
npz_files = list(npz_folder.glob("*.npz"))
|
| 56 |
if not npz_files:
|
| 57 |
+
print(f"Error: No npz files found in folder '{npz_folder_path}'")
|
| 58 |
return False
|
| 59 |
|
| 60 |
+
print(f"Found {len(npz_files)} npz files")
|
| 61 |
|
| 62 |
+
# Sort by frame number
|
| 63 |
npz_files.sort(key=lambda x: extract_frame_number(x.name))
|
| 64 |
|
| 65 |
+
# Create output folder
|
| 66 |
output_path = Path(output_folder)
|
| 67 |
output_path.mkdir(parents=True, exist_ok=True)
|
| 68 |
|
| 69 |
+
# Get video name
|
| 70 |
video_name = get_video_name_from_path(npz_folder_path)
|
| 71 |
output_file = output_path / f"{video_name}.npz"
|
| 72 |
|
| 73 |
+
# Merge data from all npz files
|
| 74 |
merged_data = {}
|
| 75 |
|
| 76 |
for npz_file in npz_files:
|
| 77 |
frame_number = extract_frame_number(npz_file.name)
|
| 78 |
+
frame_key = f"frame_{frame_number:08d}" # Format as 8 digits, e.g., frame_00000001
|
| 79 |
|
| 80 |
try:
|
| 81 |
+
# Load npz file
|
| 82 |
data = np.load(npz_file, allow_pickle=True)
|
| 83 |
|
| 84 |
+
# Store data in merged dictionary
|
| 85 |
frame_data = {}
|
| 86 |
for key in data.files:
|
| 87 |
frame_data[key] = data[key]
|
| 88 |
|
| 89 |
merged_data[frame_key] = frame_data
|
| 90 |
|
| 91 |
+
print(f"Processed: {npz_file.name} -> {frame_key}")
|
| 92 |
|
| 93 |
except Exception as e:
|
| 94 |
+
print(f"Error: Unable to load file '{npz_file}': {e}")
|
| 95 |
continue
|
| 96 |
|
| 97 |
if not merged_data:
|
| 98 |
+
print("Error: No npz files were successfully loaded")
|
| 99 |
return False
|
| 100 |
|
| 101 |
+
# Save merged data
|
| 102 |
try:
|
| 103 |
+
# Due to npz format limitations, we need special handling for nested dictionaries
|
| 104 |
+
# Flatten nested data for saving
|
| 105 |
flattened_data = {}
|
| 106 |
|
| 107 |
for frame_key, frame_data in merged_data.items():
|
|
|
|
| 109 |
combined_key = f"{frame_key}_{data_key}"
|
| 110 |
flattened_data[combined_key] = data_value
|
| 111 |
|
| 112 |
+
# Also save metadata containing frame information
|
| 113 |
frame_info = {
|
| 114 |
'frame_count': len(merged_data),
|
| 115 |
'frame_keys': list(merged_data.keys()),
|
|
|
|
| 121 |
|
| 122 |
np.savez_compressed(output_file, **flattened_data)
|
| 123 |
|
| 124 |
+
print(f"\nSuccessfully merged {len(merged_data)} frames")
|
| 125 |
+
print(f"Output file: {output_file}")
|
| 126 |
+
print(f"File size: {output_file.stat().st_size / 1024 / 1024:.2f} MB")
|
| 127 |
|
| 128 |
return True
|
| 129 |
|
| 130 |
except Exception as e:
|
| 131 |
+
print(f"Error: Failed to save merged file: {e}")
|
| 132 |
return False
|
| 133 |
|
| 134 |
def load_merged_npz(npz_file_path):
|
| 135 |
"""
|
| 136 |
+
Helper function to load merged npz file
|
| 137 |
|
| 138 |
Args:
|
| 139 |
+
npz_file_path: Path to merged npz file
|
| 140 |
|
| 141 |
Returns:
|
| 142 |
+
dict: Reconstructed frame data dictionary
|
| 143 |
"""
|
| 144 |
data = np.load(npz_file_path, allow_pickle=True)
|
| 145 |
metadata = data['_metadata'].item()
|
| 146 |
|
| 147 |
+
# Reconstruct original data structure
|
| 148 |
frames_data = {}
|
| 149 |
original_keys = metadata['original_keys']
|
| 150 |
|
|
|
|
| 158 |
|
| 159 |
return frames_data, metadata
|
| 160 |
|
| 161 |
+
def extract_dataset_name(dataset_path):
|
| 162 |
+
"""Extract dataset name from path (e.g., WLASL_train from WLASL_train_results)"""
|
| 163 |
+
dataset_name = Path(dataset_path).name
|
| 164 |
+
if dataset_name.endswith('_results'):
|
| 165 |
+
dataset_name = dataset_name[:-8] # Remove '_results' suffix
|
| 166 |
+
return dataset_name
|
| 167 |
+
|
| 168 |
+
def process_dataset_directory(dataset_path, output_folder=None):
|
| 169 |
+
"""
|
| 170 |
+
Process entire dataset directory, merging NPZ files for each video
|
| 171 |
|
| 172 |
+
Args:
|
| 173 |
+
dataset_path: Path to dataset directory containing video folders
|
| 174 |
+
output_folder: Output folder path (if None, auto-generate from dataset name)
|
| 175 |
+
"""
|
| 176 |
+
dataset_dir = Path(dataset_path)
|
| 177 |
+
if not dataset_dir.exists():
|
| 178 |
+
print(f"Error: Dataset directory '{dataset_path}' does not exist")
|
| 179 |
+
return False
|
| 180 |
|
| 181 |
+
# Extract dataset name and set output folder
|
| 182 |
+
dataset_name = extract_dataset_name(dataset_path)
|
| 183 |
+
if output_folder is None:
|
| 184 |
+
output_folder = f"./pose_dict/{dataset_name}"
|
| 185 |
|
| 186 |
+
# Find all video directories
|
| 187 |
+
video_dirs = []
|
| 188 |
+
for video_dir in sorted(dataset_dir.iterdir()):
|
| 189 |
+
if video_dir.is_dir():
|
| 190 |
+
# Check if it contains results_dwpose/npz folder
|
| 191 |
+
npz_dir = video_dir / "results_dwpose" / "npz"
|
| 192 |
+
if npz_dir.exists():
|
| 193 |
+
video_dirs.append((video_dir.name, npz_dir))
|
| 194 |
+
|
| 195 |
+
if not video_dirs:
|
| 196 |
+
print(f"Error: No video directories with NPZ files found in '{dataset_path}'")
|
| 197 |
+
return False
|
| 198 |
+
|
| 199 |
+
print(f"Dataset: {dataset_name}")
|
| 200 |
+
print(f"Found {len(video_dirs)} videos to process")
|
| 201 |
+
|
| 202 |
+
# Create output directory
|
| 203 |
+
output_path = Path(output_folder)
|
| 204 |
+
output_path.mkdir(parents=True, exist_ok=True)
|
| 205 |
+
|
| 206 |
+
# Process each video
|
| 207 |
+
successful = 0
|
| 208 |
+
failed = 0
|
| 209 |
+
|
| 210 |
+
for video_name, npz_dir in video_dirs:
|
| 211 |
+
print(f"\n{'='*50}")
|
| 212 |
+
print(f"Processing video: {video_name}")
|
| 213 |
+
print(f"{'='*50}")
|
| 214 |
|
| 215 |
+
# Check if already processed
|
| 216 |
+
output_file = output_path / f"{video_name}.npz"
|
| 217 |
+
if output_file.exists():
|
| 218 |
+
print(f"⏭️ Skipping {video_name} - already processed")
|
| 219 |
+
successful += 1
|
| 220 |
+
continue
|
| 221 |
|
| 222 |
+
# Process this video's NPZ files
|
| 223 |
+
if merge_npz_files(str(npz_dir), output_folder):
|
| 224 |
+
successful += 1
|
| 225 |
+
else:
|
| 226 |
+
failed += 1
|
| 227 |
+
print(f"❌ Failed to process {video_name}")
|
| 228 |
+
|
| 229 |
+
# Summary
|
| 230 |
+
print(f"\n{'='*70}")
|
| 231 |
+
print(f"Processing Complete!")
|
| 232 |
+
print(f"✅ Successfully processed: {successful} videos")
|
| 233 |
+
if failed > 0:
|
| 234 |
+
print(f"❌ Failed: {failed} videos")
|
| 235 |
+
print(f"📁 Output directory: {output_path}")
|
| 236 |
+
print(f"{'='*70}")
|
| 237 |
+
|
| 238 |
+
return failed == 0
|
| 239 |
+
|
| 240 |
+
def main():
|
| 241 |
+
parser = argparse.ArgumentParser(description='Merge NPZ files for videos in dataset')
|
| 242 |
+
parser.add_argument('input_path', help='Path to dataset directory or single NPZ folder')
|
| 243 |
+
parser.add_argument('--output', '-o', default=None,
|
| 244 |
+
help='Output folder path (default: ./pose_dict/dataset_name)')
|
| 245 |
+
parser.add_argument('--single', '-s', action='store_true',
|
| 246 |
+
help='Process single video NPZ folder instead of dataset directory')
|
| 247 |
+
|
| 248 |
+
args = parser.parse_args()
|
| 249 |
+
|
| 250 |
+
if args.single:
|
| 251 |
+
# Original single folder mode
|
| 252 |
+
output = args.output if args.output else './posedict'
|
| 253 |
+
success = merge_npz_files(args.input_path, output)
|
| 254 |
|
| 255 |
+
if success:
|
| 256 |
+
print("\n✅ Merge completed!")
|
| 257 |
+
|
| 258 |
+
# Example of how to read the merged file
|
| 259 |
+
video_name = get_video_name_from_path(args.input_path)
|
| 260 |
+
output_file = Path(output) / f"{video_name}.npz"
|
| 261 |
+
|
| 262 |
+
print(f"\n💡 Read example:")
|
| 263 |
+
print(f"frames_data, metadata = load_merged_npz('{output_file}')")
|
| 264 |
+
print(f"# Access frame 11 data: frames_data['frame_00000011']")
|
| 265 |
+
else:
|
| 266 |
+
print("\n❌ Merge failed!")
|
| 267 |
+
sys.exit(1)
|
| 268 |
else:
|
| 269 |
+
# Dataset directory mode (default)
|
| 270 |
+
success = process_dataset_directory(args.input_path, args.output)
|
| 271 |
+
if not success:
|
| 272 |
+
sys.exit(1)
|
| 273 |
|
| 274 |
if __name__ == "__main__":
|
| 275 |
main()
|
pose_dict/WLASL_train.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
pose_dict/WLASL_train/00335.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b0aec286acc959369930663c85b7c51ca3dfffb7005a3981851dfbd5e9f9fe15
|
| 3 |
+
size 228419
|
pose_dict/WLASL_train/00339.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8456ce9dbb579f7e85dfb8c66b7ec281aead502fbeae9f71b31e6bb2cefa6192
|
| 3 |
+
size 207040
|
pose_dict/WLASL_train/00376.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:942fbe708199c7c55ea06abc8ab85449e1f01f387c8f410802ec8917174911c7
|
| 3 |
+
size 216973
|
pose_dict/WLASL_train/00381.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:915c9b49e8a98d2857acd7f39df461988b5d739a1ba813955c2b0dd5a8af368b
|
| 3 |
+
size 120789
|
pose_dict/WLASL_train/00382.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43c3273aa3fb0f2f079b73c812260d4be932cc76e8fa82727b1502d43f42a528
|
| 3 |
+
size 149383
|
pose_dict/WLASL_train/00414.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:383fe473f1b52fc05e3f916f06dad39fd1ba6f09c27fa2ee39964c3894a06a3a
|
| 3 |
+
size 209918
|
pose_dict/WLASL_train/00415.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6dcfe7c525f400361798c709967960a448239068e012619479a9d68d5ede98f8
|
| 3 |
+
size 159103
|
pose_dict/WLASL_train/00421.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51ceeea23c28108abf77673d941880cda21325888f5878a7efd4133955b4a6c0
|
| 3 |
+
size 111950
|
pose_dict/WLASL_train/00426.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5568ab4de1b9e6be525bd8386b4f7d5d2dd54c49c3aa22a49bfaffa5dc7ee5dc
|
| 3 |
+
size 320729
|
pose_dict/WLASL_train/00430.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c453f78bf034afe7490ec62049bfb775f889e5a858b98b8925474ef043da3dec
|
| 3 |
+
size 178629
|
pose_dict/WLASL_train/00431.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:61748ade6248d8ad6f73a03653f49ff4eb398967910874c184e154b1ea4584c2
|
| 3 |
+
size 399268
|
pose_dict/WLASL_train/00435.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37cd687a406fae29b6ab980c9dc9e6fd9266a44d3ad99b3c054bc55483c09059
|
| 3 |
+
size 337910
|
pose_dict/WLASL_train/00583.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c78f383276cd7c726b55d10e22ca7e06f1bde03ae850e4dfa20a7a0249597887
|
| 3 |
+
size 125977
|
pose_dict/WLASL_train/00584.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3d8e4c52764199c2cc75ee40b52b145f468033bd744b29205b7255d6eb103b3
|
| 3 |
+
size 140504
|
pose_dict/WLASL_train/00586.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b29151c0ed4ac2cfed191d2254fef88b919c73445a6fe940ac820a87a6476002
|
| 3 |
+
size 129856
|
pose_dict/WLASL_train/00592.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a919d596d89ac615e2d32cc413a1891c1f80ce4ea29d08157a8e1f3e934d8668
|
| 3 |
+
size 490385
|
pose_dict/WLASL_train/00593.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ace036bb0756135e01af856f7aadda92536e33de6e0f3469904a22209bf0c298
|
| 3 |
+
size 119512
|
pose_dict/WLASL_train/00597.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39f96d7b918be686fbd769c7afe59b118ea7e76f01a98ed40f5b812c2d16fc59
|
| 3 |
+
size 421490
|
pose_dict/WLASL_train/00600.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:47f73098860b853f6961fa584c3377f807b0a71f6d6b8a1dbf4d0a226352203a
|
| 3 |
+
size 99575
|
pose_dict/WLASL_train/00603.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f324f21ae4f178741b6b396ccacd854cffaf2890b9f506cefc5adfa7e724366
|
| 3 |
+
size 277144
|
pose_dict/WLASL_train/00626.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5db7e80d31e13b52ca7ad8a5c2c841221f21fe254ef1d21444ae60245d791cbd
|
| 3 |
+
size 185403
|
pose_dict/WLASL_train/00627.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d807f1bd7e86e9c12cbaefc339744e0497900951a06165fe331925dbe22379fb
|
| 3 |
+
size 102741
|
pose_dict/WLASL_train/00628.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9990a01f0f4a2f6d87e9104b4c2fb5bb133e210868954cc649f0b5ebc906760
|
| 3 |
+
size 115877
|
pose_dict/WLASL_train/00629.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:583ae7403507561ff3ac18e5942ede90edf4147b1e0295e98094b958f699a771
|
| 3 |
+
size 494487
|
pose_dict/WLASL_train/00631.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7686e9702790c4b572dc930daae302e46d04ea332663020bc538929bbf2b2ec9
|
| 3 |
+
size 255949
|
pose_dict/WLASL_train/00633.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b345bf36dc10b4b94e062546cc39468924ca3fb44ff30e581b863dbda7e74a9
|
| 3 |
+
size 83459
|
pose_dict/WLASL_train/00634.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ff8dfc35b287958a068ea210c7ff0dc2bf0630a82c28742ee438d09bb90aeff
|
| 3 |
+
size 134911
|
pose_dict/WLASL_train/00663.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd16e77154baf4f989bfe4a76fff2459609ac92d86c3b84f4297f5a037052d97
|
| 3 |
+
size 462869
|
pose_dict/WLASL_train/00664.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:675516621f12866191bd69e0339208add9a4e204948485f845be2028754ad798
|
| 3 |
+
size 389982
|
pose_dict/WLASL_train/00666.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3ad19403d8cd7fca7379ef14befe53fe1447b702117d6f3c644e13a878a1f87
|
| 3 |
+
size 120632
|
pose_dict/WLASL_train/00668.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0f9fcaa6e0ae1d0824eb5f449eeedf48cc97f3cc77bf6a6de16f135e687bf64
|
| 3 |
+
size 261804
|
pose_dict/WLASL_train/00689.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cb80baef06d62a8c64859bafe9f2290760f3b6da8d04b8e27368533931491ad8
|
| 3 |
+
size 289613
|
pose_dict/WLASL_train/00690.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:83d4a474d89ec52bac66bd2c8ee7145647047338b42a2828cb993b6ede7cd325
|
| 3 |
+
size 438530
|
pose_dict/WLASL_train/00692.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b67e4b82e5cb79fc2f0689cc15ff42803869cdd01c0204c9c140b9ca05a91bdf
|
| 3 |
+
size 217217
|
pose_dict/WLASL_train/00832.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:636ec942bedf8b6d87fdd115766d5a230ed8ff14f8efeb34ec705b774fe02f46
|
| 3 |
+
size 281744
|