Spaces:
Running
on
Zero
Running
on
Zero
Update hy3dgen/shapegen/utils.py
Browse files
hy3dgen/shapegen/utils.py
CHANGED
|
@@ -100,10 +100,13 @@ def smart_load_model(
|
|
| 100 |
if not os.path.exists(model_path):
|
| 101 |
logger.info('Model path not exists, try to download from huggingface')
|
| 102 |
try:
|
| 103 |
-
import
|
| 104 |
-
#
|
| 105 |
-
path =
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
| 107 |
except ImportError:
|
| 108 |
logger.warning(
|
| 109 |
"You need to install HuggingFace Hub to load models from the hub."
|
|
@@ -121,3 +124,4 @@ def smart_load_model(
|
|
| 121 |
config_path = os.path.join(model_path, 'config.yaml')
|
| 122 |
ckpt_path = os.path.join(model_path, ckpt_name)
|
| 123 |
return config_path, ckpt_path
|
|
|
|
|
|
| 100 |
if not os.path.exists(model_path):
|
| 101 |
logger.info('Model path not exists, try to download from huggingface')
|
| 102 |
try:
|
| 103 |
+
from huggingface_hub import snapshot_download
|
| 104 |
+
# 只下载指定子目录
|
| 105 |
+
path = snapshot_download(
|
| 106 |
+
repo_id=original_model_path,
|
| 107 |
+
allow_patterns=[f"{subfolder}/*"], # 关键修改:模式匹配子文件夹
|
| 108 |
+
)
|
| 109 |
+
model_path = os.path.join(path, subfolder) # 保持路径拼接逻辑不变
|
| 110 |
except ImportError:
|
| 111 |
logger.warning(
|
| 112 |
"You need to install HuggingFace Hub to load models from the hub."
|
|
|
|
| 124 |
config_path = os.path.join(model_path, 'config.yaml')
|
| 125 |
ckpt_path = os.path.join(model_path, ckpt_name)
|
| 126 |
return config_path, ckpt_path
|
| 127 |
+
|