FangSen9000 commited on
Commit ·
5b5507b
1
Parent(s): cfb7d5a
Add style suffix
Browse files- README.md +1 -1
- text2pose.py +25 -10
README.md
CHANGED
|
@@ -20,7 +20,7 @@ python text2pose.py --gloss "good morning afternoon" --scale-y 1.4 --scale-x 1.3
|
|
| 20 |
|
| 21 |
or
|
| 22 |
|
| 23 |
-
python text2pose.py --gloss "where is my cat" --scale-y 1.5 --scale-x 1.5 --npz-interpolation 20 --width 512 --height 512 --fps 30 --hide-torso-lines false
|
| 24 |
```
|
| 25 |
|
| 26 |
second, change `generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4` & `ref_img_dict/03.jpeg`, and run:
|
|
|
|
| 20 |
|
| 21 |
or
|
| 22 |
|
| 23 |
+
python text2pose.py --gloss "where is my cat" --scale-y 1.5 --scale-x 1.5 --npz-interpolation 20 --width 512 --height 512 --fps 30 --hide-torso-lines false --draw-style openpose
|
| 24 |
```
|
| 25 |
|
| 26 |
second, change `generated_pose_video/GOOD_MORNING_AFTERNOON_25073_36863_01435_20250804_160832.mp4` & `ref_img_dict/03.jpeg`, and run:
|
text2pose.py
CHANGED
|
@@ -30,10 +30,11 @@ OUTPUT_DIR = "generated_pose_video" # Output video directory
|
|
| 30 |
|
| 31 |
|
| 32 |
class SignLanguageQA:
|
| 33 |
-
def __init__(self):
|
| 34 |
self.gloss_data = None
|
| 35 |
self.load_json_mapping()
|
| 36 |
self.detector = None # Lazy load DWpose detector when needed
|
|
|
|
| 37 |
|
| 38 |
def load_json_mapping(self):
|
| 39 |
"""Load JSON mapping file"""
|
|
@@ -760,12 +761,18 @@ class SignLanguageQA:
|
|
| 760 |
|
| 761 |
for gloss in gloss_list:
|
| 762 |
matched_videos = self.find_gloss_videos(gloss)
|
|
|
|
| 763 |
|
| 764 |
if not matched_videos:
|
| 765 |
print(f"❌ '{gloss}' -> No matching Pose unit found")
|
| 766 |
continue
|
| 767 |
|
| 768 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
|
| 770 |
# Evaluate all videos and select the best one based on quality and centering
|
| 771 |
candidate_videos = []
|
|
@@ -1176,7 +1183,11 @@ class SignLanguageQA:
|
|
| 1176 |
suffix = f"_{smoothing_method}" if smoothing_method != 'none' else ""
|
| 1177 |
if npz_interpolation_frames > 0:
|
| 1178 |
suffix = f"_npz{npz_interpolation_frames}"
|
| 1179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1180 |
|
| 1181 |
# Generate video
|
| 1182 |
success = self.generate_video_from_glosses(
|
|
@@ -1184,7 +1195,8 @@ class SignLanguageQA:
|
|
| 1184 |
smoothing_frames=smoothing_frames,
|
| 1185 |
smoothing_method=smoothing_method,
|
| 1186 |
npz_interpolation_frames=npz_interpolation_frames,
|
| 1187 |
-
hide_torso_lines=False
|
|
|
|
| 1188 |
)
|
| 1189 |
|
| 1190 |
except KeyboardInterrupt:
|
|
@@ -1227,10 +1239,10 @@ def main():
|
|
| 1227 |
help='Smoothing frames (default: 5)')
|
| 1228 |
parser.add_argument('--npz-interpolation', type=int, default=0,
|
| 1229 |
help='Number of NPZ interpolation frames between glosses (default: 0)')
|
| 1230 |
-
parser.add_argument('--scale-x', type=float, default=1.
|
| 1231 |
-
help='Progressive X-axis scaling factor (default: 1.
|
| 1232 |
-
parser.add_argument('--scale-y', type=float, default=1.
|
| 1233 |
-
help='Progressive Y-axis scaling factor (default: 1.
|
| 1234 |
parser.add_argument('--hide-torso-lines', type=str, choices=['true', 'false'], default='false',
|
| 1235 |
help='Hide torso lines from neck to hips (set to black). Choices: true/false (default: false)')
|
| 1236 |
parser.add_argument('--ref-image-path', type=str, default=None,
|
|
@@ -1239,11 +1251,13 @@ def main():
|
|
| 1239 |
help='Drawing style for pose visualization. controlnext: advanced features with confidence-based coloring. openpose: simpler classic style. (default: controlnext)')
|
| 1240 |
parser.add_argument('--normalize-pose', type=str, choices=['true', 'false'], default='true',
|
| 1241 |
help='Normalize pose data to standard coordinate system. This ensures different videos are in the same coordinate space, reducing inconsistency from different video sources. (default: true)')
|
|
|
|
|
|
|
| 1242 |
|
| 1243 |
args = parser.parse_args()
|
| 1244 |
|
| 1245 |
# Initialize QA system
|
| 1246 |
-
qa_system = SignLanguageQA()
|
| 1247 |
|
| 1248 |
# If gloss parameter provided, process directly
|
| 1249 |
if args.gloss:
|
|
@@ -1262,7 +1276,8 @@ def main():
|
|
| 1262 |
video_ids.append(videos[0]) # Take first video
|
| 1263 |
|
| 1264 |
video_id_str = "_".join(video_ids) if video_ids else "novideo"
|
| 1265 |
-
|
|
|
|
| 1266 |
|
| 1267 |
if args.smoothing != 'none':
|
| 1268 |
print(f"🌊 Using {args.smoothing} smoothing ({args.smoothing_frames} frames)")
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
class SignLanguageQA:
|
| 33 |
+
def __init__(self, max_candidates=10):
|
| 34 |
self.gloss_data = None
|
| 35 |
self.load_json_mapping()
|
| 36 |
self.detector = None # Lazy load DWpose detector when needed
|
| 37 |
+
self.max_candidates = max_candidates
|
| 38 |
|
| 39 |
def load_json_mapping(self):
|
| 40 |
"""Load JSON mapping file"""
|
|
|
|
| 761 |
|
| 762 |
for gloss in gloss_list:
|
| 763 |
matched_videos = self.find_gloss_videos(gloss)
|
| 764 |
+
total_matches = len(matched_videos)
|
| 765 |
|
| 766 |
if not matched_videos:
|
| 767 |
print(f"❌ '{gloss}' -> No matching Pose unit found")
|
| 768 |
continue
|
| 769 |
|
| 770 |
+
if self.max_candidates and total_matches > self.max_candidates:
|
| 771 |
+
print(f" ℹ️ Limiting candidates to first {self.max_candidates} (out of {total_matches}) for efficiency")
|
| 772 |
+
matched_videos = matched_videos[:self.max_candidates]
|
| 773 |
+
|
| 774 |
+
print(f"🎯 '{gloss}' -> Found {total_matches} Unit in Pose Dict")
|
| 775 |
+
print(f" 🔍 Evaluating {len(matched_videos)} candidate(s)")
|
| 776 |
|
| 777 |
# Evaluate all videos and select the best one based on quality and centering
|
| 778 |
candidate_videos = []
|
|
|
|
| 1183 |
suffix = f"_{smoothing_method}" if smoothing_method != 'none' else ""
|
| 1184 |
if npz_interpolation_frames > 0:
|
| 1185 |
suffix = f"_npz{npz_interpolation_frames}"
|
| 1186 |
+
|
| 1187 |
+
draw_style = 'controlnext'
|
| 1188 |
+
print(f"🎨 Using {draw_style} drawing style")
|
| 1189 |
+
style_suffix = f"_{draw_style}_style"
|
| 1190 |
+
output_file = Path(OUTPUT_DIR) / f"{gloss_str}_{timestamp}{suffix}{style_suffix}.mp4"
|
| 1191 |
|
| 1192 |
# Generate video
|
| 1193 |
success = self.generate_video_from_glosses(
|
|
|
|
| 1195 |
smoothing_frames=smoothing_frames,
|
| 1196 |
smoothing_method=smoothing_method,
|
| 1197 |
npz_interpolation_frames=npz_interpolation_frames,
|
| 1198 |
+
hide_torso_lines=False,
|
| 1199 |
+
draw_style=draw_style
|
| 1200 |
)
|
| 1201 |
|
| 1202 |
except KeyboardInterrupt:
|
|
|
|
| 1239 |
help='Smoothing frames (default: 5)')
|
| 1240 |
parser.add_argument('--npz-interpolation', type=int, default=0,
|
| 1241 |
help='Number of NPZ interpolation frames between glosses (default: 0)')
|
| 1242 |
+
parser.add_argument('--scale-x', type=float, default=1.5,
|
| 1243 |
+
help='Progressive X-axis scaling factor (default: 1.5)')
|
| 1244 |
+
parser.add_argument('--scale-y', type=float, default=1.5,
|
| 1245 |
+
help='Progressive Y-axis scaling factor (default: 1.5)')
|
| 1246 |
parser.add_argument('--hide-torso-lines', type=str, choices=['true', 'false'], default='false',
|
| 1247 |
help='Hide torso lines from neck to hips (set to black). Choices: true/false (default: false)')
|
| 1248 |
parser.add_argument('--ref-image-path', type=str, default=None,
|
|
|
|
| 1251 |
help='Drawing style for pose visualization. controlnext: advanced features with confidence-based coloring. openpose: simpler classic style. (default: controlnext)')
|
| 1252 |
parser.add_argument('--normalize-pose', type=str, choices=['true', 'false'], default='true',
|
| 1253 |
help='Normalize pose data to standard coordinate system. This ensures different videos are in the same coordinate space, reducing inconsistency from different video sources. (default: true)')
|
| 1254 |
+
parser.add_argument('--max-candidates', type=int, default=10,
|
| 1255 |
+
help='Maximum number of NPZ candidates evaluated per gloss (default: 10, set 0 for unlimited)')
|
| 1256 |
|
| 1257 |
args = parser.parse_args()
|
| 1258 |
|
| 1259 |
# Initialize QA system
|
| 1260 |
+
qa_system = SignLanguageQA(max_candidates=max(0, args.max_candidates))
|
| 1261 |
|
| 1262 |
# If gloss parameter provided, process directly
|
| 1263 |
if args.gloss:
|
|
|
|
| 1276 |
video_ids.append(videos[0]) # Take first video
|
| 1277 |
|
| 1278 |
video_id_str = "_".join(video_ids) if video_ids else "novideo"
|
| 1279 |
+
style_suffix = f"_{args.draw_style}_style"
|
| 1280 |
+
output_file = Path(OUTPUT_DIR) / f"{gloss_str}_{video_id_str}_{timestamp}{suffix}{style_suffix}.mp4"
|
| 1281 |
|
| 1282 |
if args.smoothing != 'none':
|
| 1283 |
print(f"🌊 Using {args.smoothing} smoothing ({args.smoothing_frames} frames)")
|