yolozyk commited on
Commit
d24edb6
·
verified ·
1 Parent(s): df91e2b

Update src/generate_utils/generate.py

Browse files
Files changed (1) hide show
  1. src/generate_utils/generate.py +16 -4
src/generate_utils/generate.py CHANGED
@@ -26,8 +26,8 @@ class PressureGenerator:
26
  }
27
 
28
  def __init__(self,
29
- ckpt_dir="generate_utils/lib/ckpt/pressurepose_20251222_180032",
30
- smpl_model_dir="E:/pyku/smpl_models",
31
  device="cpu"):
32
  """
33
  初始化生成器:加载配置、权重和 SMPL 模型。
@@ -58,7 +58,13 @@ class PressureGenerator:
58
  def _load_config(self):
59
  config_path = os.path.join(self.ckpt_dir, 'config.yaml')
60
  if not os.path.exists(config_path):
61
- raise FileNotFoundError(f"Config not found at {config_path}")
 
 
 
 
 
 
62
  with open(config_path, 'r') as f:
63
  return yaml.safe_load(f)
64
 
@@ -67,7 +73,13 @@ class PressureGenerator:
67
  ckpt_path = os.path.join(self.ckpt_dir, 'ckpts', 'best_model.pth')
68
 
69
  if not os.path.exists(ckpt_path):
70
- raise FileNotFoundError(f"Checkpoint not found at {ckpt_path}")
 
 
 
 
 
 
71
 
72
  checkpoint = torch.load(ckpt_path, map_location=self.device)
73
  model.load_state_dict(checkpoint['model_state_dict'])
 
26
  }
27
 
28
  def __init__(self,
29
+ ckpt_dir="src/generate_utils/lib/ckpt/pressurepose_20251222_180032",
30
+ smpl_model_dir="src/smpl_models",
31
  device="cpu"):
32
  """
33
  初始化生成器:加载配置、权重和 SMPL 模型。
 
58
  def _load_config(self):
59
  config_path = os.path.join(self.ckpt_dir, 'config.yaml')
60
  if not os.path.exists(config_path):
61
+ from huggingface_hub import snapshot_download
62
+ snapshot_download(
63
+ "yolozyk/PaGe",
64
+ local_dir="src/generate_utils/lib/ckpt/",
65
+ local_dir_use_symlinks=False,
66
+ ignore_patterns=["*.safetensors", ".gitattributes"],
67
+ )
68
  with open(config_path, 'r') as f:
69
  return yaml.safe_load(f)
70
 
 
73
  ckpt_path = os.path.join(self.ckpt_dir, 'ckpts', 'best_model.pth')
74
 
75
  if not os.path.exists(ckpt_path):
76
+ from huggingface_hub import snapshot_download
77
+ snapshot_download(
78
+ "yolozyk/PaGe",
79
+ local_dir="src/generate_utils/lib/ckpt/",
80
+ local_dir_use_symlinks=False,
81
+ ignore_patterns=["*.safetensors", ".gitattributes"],
82
+ )
83
 
84
  checkpoint = torch.load(ckpt_path, map_location=self.device)
85
  model.load_state_dict(checkpoint['model_state_dict'])