Spaces:
Running
on
Zero
Running
on
Zero
Update trellis/pipelines/__init__.py
Browse files- trellis/pipelines/__init__.py +25 -24
trellis/pipelines/__init__.py
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
-
from . import samplers
|
2 |
-
from .trellis_image_to_3d import TrellisImageTo3DPipeline
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
import
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
1 |
+
from . import samplers
|
2 |
+
from .trellis_image_to_3d import TrellisImageTo3DPipeline
|
3 |
+
from .trellis_text_to_3d import TrellisTextTo3DPipeline
|
4 |
+
|
5 |
+
|
6 |
+
def from_pretrained(path: str):
|
7 |
+
"""
|
8 |
+
Load a pipeline from a model folder or a Hugging Face model hub.
|
9 |
+
|
10 |
+
Args:
|
11 |
+
path: The path to the model. Can be either local path or a Hugging Face model name.
|
12 |
+
"""
|
13 |
+
import os
|
14 |
+
import json
|
15 |
+
is_local = os.path.exists(f"{path}/pipeline.json")
|
16 |
+
|
17 |
+
if is_local:
|
18 |
+
config_file = f"{path}/pipeline.json"
|
19 |
+
else:
|
20 |
+
from huggingface_hub import hf_hub_download
|
21 |
+
config_file = hf_hub_download(path, "pipeline.json")
|
22 |
+
|
23 |
+
with open(config_file, 'r') as f:
|
24 |
+
config = json.load(f)
|
25 |
+
return globals()[config['name']].from_pretrained(path)
|