FangSen9000 commited on
Commit
6178c29
·
1 Parent(s): ac40945

Fix the input issue of the reference image

Browse files
One-to-All-Animation/video-generation/inference_1.3b.py CHANGED
@@ -76,6 +76,26 @@ def resolve_pose_video_path(pose_identifier: str) -> str:
76
  )
77
 
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  def resizecrop(image, th, tw):
80
  w, h = image.size
81
  if h / w > th / tw:
@@ -371,7 +391,8 @@ def unified_worker(rank, world_size, task_list, ckpt_path, use_direct_paths=Fals
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)
@@ -391,9 +412,17 @@ def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2", use_d
391
  if not pose_cfg: pose_cfg = pose_g
392
  else: pose_cfg = float(pose_cfg)
393
 
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:
@@ -402,13 +431,13 @@ def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2", use_d
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,
@@ -469,6 +498,12 @@ if __name__ == "__main__":
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",
@@ -488,7 +523,8 @@ if __name__ == "__main__":
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 读取")
 
76
  )
77
 
78
 
79
+ def resolve_ref_image_path(ref_identifier: str) -> str:
80
+ """Return an absolute ref image path, searching ref_img_dict when needed."""
81
+ if not ref_identifier:
82
+ raise ValueError("ref_identifier is required to resolve a reference image path")
83
+
84
+ candidates = []
85
+ expanded = os.path.expanduser(ref_identifier)
86
+ candidates.append(expanded)
87
+ if not os.path.isabs(expanded):
88
+ candidates.append(os.path.join(ref_image_dir, ref_identifier))
89
+
90
+ for candidate in candidates:
91
+ if candidate and os.path.exists(candidate):
92
+ return os.path.abspath(candidate)
93
+
94
+ raise FileNotFoundError(
95
+ f"❌ Reference image not found. Tried: {', '.join(os.path.abspath(c) for c in candidates)}"
96
+ )
97
+
98
+
99
  def resizecrop(image, th, tw):
100
  w, h = image.size
101
  if h / w > th / tw:
 
391
  torch.cuda.empty_cache()
392
 
393
 
394
+ def run_all_tasks(ckpt_path, img_g, pose_g, cache_dir_root="input_cache2",
395
+ use_direct_paths=False, pose_video_override=None, ref_image_override=None):
396
  """扫描 cache 目录,跑全部任务"""
397
  # Modified: Direct paths mode for StableSigner3 generated videos
398
  # Format: (ref_image_path, pose_video_path, new_h, new_w, ref_cfg, pose_cfg, prompt)
 
412
  if not pose_cfg: pose_cfg = pose_g
413
  else: pose_cfg = float(pose_cfg)
414
 
415
+ if ref_image_override:
416
+ try:
417
+ ref_target = resolve_ref_image_path(ref_image_override)
418
+ except (FileNotFoundError, ValueError) as exc:
419
+ print(exc)
420
+ continue
421
+ else:
422
+ ref_target = ref_path
423
+ if not os.path.exists(ref_target):
424
+ print(f"❌ Reference image not found: {ref_target}")
425
+ continue
426
 
427
  pose_target = pose_video_override if pose_video_override else pose_video_path
428
  try:
 
431
  print(exc)
432
  continue
433
 
434
+ refname = os.path.splitext(os.path.basename(ref_target))[0]
435
  vidname = os.path.splitext(os.path.basename(resolved_pose_path))[0]
436
  job_name = f"ref_{refname}_vid_{vidname}"
437
 
438
  # Create a simple dict to hold paths
439
  task_info = {
440
+ 'ref_path': ref_target,
441
  'pose_video_path': resolved_pose_path,
442
  'job_name': job_name,
443
  'new_h': new_h,
 
498
  default=None,
499
  help="Pose video path or filename inside generated_pose_video"
500
  )
501
+ parser.add_argument(
502
+ "--ref_image",
503
+ type=str,
504
+ default=None,
505
+ help="Reference image path (absolute or relative). Defaults to square2.jpg"
506
+ )
507
  parser.add_argument(
508
  "--use_cache_mode",
509
  action="store_true",
 
523
  img_g,
524
  pose_g,
525
  use_direct_paths=True,
526
+ pose_video_override=args.pose_video,
527
+ ref_image_override=args.ref_image
528
  )
529
  else:
530
  print("📁 使用缓存模式: 从 input_cache 读取")
One-to-All-Animation/video-generation/run_batch.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ source /research/cbim/vast/sf895/miniforge3/bin/activate one-to-all
5
+
6
+ cd "$(dirname "$0")"
7
+
8
+ #cd /research/cbim/vast/sf895/code/StableSigner/One-to-All-Animation/video-generation
9
+ #conda activate one-to-all
10
+ CUDA_VISIBLE_DEVICES=0 python inference_1.3b.py --pose_video HELLO_GOOD_MORNING_20251215_142658_openpose_style.mp4 --ref_image square1.png
11
+ CUDA_VISIBLE_DEVICES=1 python inference_1.3b.py --pose_video HELLO_WORLD_20251215_142017_openpose_style.mp4 --ref_image square2.png
12
+ CUDA_VISIBLE_DEVICES=2 python inference_1.3b.py --pose_video I_GO_SCHOOL_LATER_20251215_142204_openpose_style.mp4 --ref_image square3.png
13
+ CUDA_VISIBLE_DEVICES=3 python inference_1.3b.py --pose_video I_NEED_HELP_PLEASE_20251215_142045_openpose_style.mp4 --ref_image square4.png
14
+ CUDA_VISIBLE_DEVICES=4 python inference_1.3b.py --pose_video TODAY_WEATHER_NICE_20251215_142126_openpose_style.mp4 --ref_image square5.png
15
+ CUDA_VISIBLE_DEVICES=5 python inference_1.3b.py --pose_video WEHRE_IS_MY_CAT_20251215_142307_openpose_style.mp4 --ref_image square6.png
16
+ CUDA_VISIBLE_DEVICES=6 python inference_1.3b.py --pose_video TODAY_WEATHER_NICE_20251215_142126_openpose_style.mp4 --ref_image square2.png
17
+ CUDA_VISIBLE_DEVICES=7 python inference_1.3b.py --pose_video I_GO_SCHOOL_LATER_20251215_142204_openpose_style.mp4 --ref_image square8.png
easy_dwpose/__pycache__/__init__.cpython-312.pyc CHANGED
Binary files a/easy_dwpose/__pycache__/__init__.cpython-312.pyc and b/easy_dwpose/__pycache__/__init__.cpython-312.pyc differ