FangSen9000 commited on
Commit
c0b93a0
·
1 Parent(s): 1d608cf

Add pose2vid which can perform command-line reasoning

Browse files
One-to-All-Animation/video-generation/inference_1.3b.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import glob
3
  import torch
@@ -52,6 +53,29 @@ controlnet_conditioning_scale = 1.0
52
  case1 = False
53
 
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  def resizecrop(image, th, tw):
56
  w, h = image.size
57
  if h / w > th / tw:
@@ -347,7 +371,7 @@ def unified_worker(rank, world_size, task_list, ckpt_path, use_direct_paths=Fals
347
  torch.cuda.empty_cache()
348
 
349
 
350
- def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2", use_direct_paths=False):
351
  """扫描 cache 目录,跑全部任务"""
352
  # Modified: Direct paths mode for StableSigner3 generated videos
353
  # Format: (ref_image_path, pose_video_path, new_h, new_w, ref_cfg, pose_cfg, prompt)
@@ -356,7 +380,7 @@ def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2", use_d
356
  task_list = [
357
  # Example: Use your generated pose video
358
  (f"{ref_image_dir}/square2.jpg",
359
- f"{pose_video_dir}/I_NEED_HELP_PLEASE_28794_37894_69364_43226_20251212_150521.mp4",
360
  "", "", "", "", ""),
361
  ]
362
 
@@ -370,18 +394,22 @@ def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2", use_d
370
  if not os.path.exists(ref_path):
371
  print(f"❌ Reference image not found: {ref_path}")
372
  continue
373
- if not os.path.exists(pose_video_path):
374
- print(f"❌ Pose video not found: {pose_video_path}")
 
 
 
 
375
  continue
376
 
377
  refname = os.path.splitext(os.path.basename(ref_path))[0]
378
- vidname = os.path.splitext(os.path.basename(pose_video_path))[0]
379
  job_name = f"ref_{refname}_vid_{vidname}"
380
 
381
  # Create a simple dict to hold paths
382
  task_info = {
383
  'ref_path': ref_path,
384
- 'pose_video_path': pose_video_path,
385
  'job_name': job_name,
386
  'new_h': new_h,
387
  'new_w': new_w,
@@ -434,15 +462,34 @@ def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2", use_d
434
  )
435
 
436
  if __name__ == "__main__":
437
- # Modified: Set to True to use direct paths from generated_pose_video
438
- USE_DIRECT_PATHS = True
 
 
 
 
 
 
 
 
 
 
 
 
 
439
 
440
  for ckpt in ckpt_paths:
441
  for img_g, pose_g in default_cfg_combos:
442
  print(f"\n===== ckpt: {ckpt} | img_g={img_g} | pose_g={pose_g} =====")
443
  if USE_DIRECT_PATHS:
444
  print("📁 使用直接路径模式: 从 generated_pose_video 读取")
445
- run_all_tasks(ckpt, img_g, pose_g, use_direct_paths=True)
 
 
 
 
 
 
446
  else:
447
  print("📁 使用缓存模式: 从 input_cache 读取")
448
  run_all_tasks(ckpt, img_g, pose_g, cache_dir_root=cache_base_dir, use_direct_paths=False)
 
1
+ import argparse
2
  import os
3
  import glob
4
  import torch
 
53
  case1 = False
54
 
55
 
56
+ def resolve_pose_video_path(pose_identifier: str) -> str:
57
+ """Return an absolute pose video path, searching generated_pose_video when needed."""
58
+ if not pose_identifier:
59
+ raise ValueError("pose_identifier is required to resolve a pose video path")
60
+
61
+ candidates = []
62
+ expanded = os.path.expanduser(pose_identifier)
63
+ candidates.append(expanded)
64
+
65
+ # Always allow fallback to generated_pose_video by name.
66
+ candidates.append(os.path.join(pose_video_dir, pose_identifier))
67
+ if not os.path.splitext(pose_identifier)[1]:
68
+ candidates.append(os.path.join(pose_video_dir, f"{pose_identifier}.mp4"))
69
+
70
+ for candidate in candidates:
71
+ if candidate and os.path.exists(candidate):
72
+ return os.path.abspath(candidate)
73
+
74
+ raise FileNotFoundError(
75
+ f"❌ Pose video not found. Tried: {', '.join(os.path.abspath(c) for c in candidates)}"
76
+ )
77
+
78
+
79
  def resizecrop(image, th, tw):
80
  w, h = image.size
81
  if h / w > th / tw:
 
371
  torch.cuda.empty_cache()
372
 
373
 
374
+ def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2", use_direct_paths=False, pose_video_override=None):
375
  """扫描 cache 目录,跑全部任务"""
376
  # Modified: Direct paths mode for StableSigner3 generated videos
377
  # Format: (ref_image_path, pose_video_path, new_h, new_w, ref_cfg, pose_cfg, prompt)
 
380
  task_list = [
381
  # Example: Use your generated pose video
382
  (f"{ref_image_dir}/square2.jpg",
383
+ f"{pose_video_dir}/WHERE_IS_MY_CAT_63084_22116_37469_65313_20251213_233807_openpose_style.mp4",
384
  "", "", "", "", ""),
385
  ]
386
 
 
394
  if not os.path.exists(ref_path):
395
  print(f"❌ Reference image not found: {ref_path}")
396
  continue
397
+
398
+ pose_target = pose_video_override if pose_video_override else pose_video_path
399
+ try:
400
+ resolved_pose_path = resolve_pose_video_path(pose_target)
401
+ except (FileNotFoundError, ValueError) as exc:
402
+ print(exc)
403
  continue
404
 
405
  refname = os.path.splitext(os.path.basename(ref_path))[0]
406
+ vidname = os.path.splitext(os.path.basename(resolved_pose_path))[0]
407
  job_name = f"ref_{refname}_vid_{vidname}"
408
 
409
  # Create a simple dict to hold paths
410
  task_info = {
411
  'ref_path': ref_path,
412
+ 'pose_video_path': resolved_pose_path,
413
  'job_name': job_name,
414
  'new_h': new_h,
415
  'new_w': new_w,
 
462
  )
463
 
464
  if __name__ == "__main__":
465
+ parser = argparse.ArgumentParser(description="StableSigner3 One-to-All inference")
466
+ parser.add_argument(
467
+ "--pose_video",
468
+ type=str,
469
+ default=None,
470
+ help="Pose video path or filename inside generated_pose_video"
471
+ )
472
+ parser.add_argument(
473
+ "--use_cache_mode",
474
+ action="store_true",
475
+ help="Use cached input mode instead of direct reference/pose paths"
476
+ )
477
+ args = parser.parse_args()
478
+
479
+ USE_DIRECT_PATHS = not args.use_cache_mode
480
 
481
  for ckpt in ckpt_paths:
482
  for img_g, pose_g in default_cfg_combos:
483
  print(f"\n===== ckpt: {ckpt} | img_g={img_g} | pose_g={pose_g} =====")
484
  if USE_DIRECT_PATHS:
485
  print("📁 使用直接路径模式: 从 generated_pose_video 读取")
486
+ run_all_tasks(
487
+ ckpt,
488
+ img_g,
489
+ pose_g,
490
+ use_direct_paths=True,
491
+ pose_video_override=args.pose_video
492
+ )
493
  else:
494
  print("📁 使用缓存模式: 从 input_cache 读取")
495
  run_all_tasks(ckpt, img_g, pose_g, cache_dir_root=cache_base_dir, use_direct_paths=False)
prompt2gloss/example_input.text ADDED
The diff for this file is too large to render. See raw diff
 
prompt2gloss/example_output.text ADDED
The diff for this file is too large to render. See raw diff