Spaces:
Runtime error
Runtime error
Update freesplatter/webui/runner.py
Browse files
freesplatter/webui/runner.py
CHANGED
|
@@ -16,7 +16,7 @@ from omegaconf import OmegaConf
|
|
| 16 |
from einops import rearrange
|
| 17 |
from scipy.spatial.transform import Rotation
|
| 18 |
from safetensors import safe_open
|
| 19 |
-
from huggingface_hub import hf_hub_download
|
| 20 |
|
| 21 |
from transformers import AutoModelForImageSegmentation
|
| 22 |
from diffusers import DiffusionPipeline, EulerAncestralDiscreteScheduler
|
|
@@ -78,7 +78,6 @@ class FreeSplatterRunner:
|
|
| 78 |
self.rembg = AutoModelForImageSegmentation.from_pretrained(
|
| 79 |
"briaai/RMBG-2.0",
|
| 80 |
trust_remote_code=True,
|
| 81 |
-
cache_dir='ckpts/',
|
| 82 |
)
|
| 83 |
self.rembg.eval()
|
| 84 |
|
|
@@ -87,7 +86,6 @@ class FreeSplatterRunner:
|
|
| 87 |
"sudo-ai/zero123plus-v1.1",
|
| 88 |
custom_pipeline="sudo-ai/zero123plus-pipeline",
|
| 89 |
torch_dtype=torch.float16,
|
| 90 |
-
cache_dir="ckpts/",
|
| 91 |
)
|
| 92 |
pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
| 93 |
pipeline.scheduler.config, timestep_spacing='trailing'
|
|
@@ -98,15 +96,15 @@ class FreeSplatterRunner:
|
|
| 98 |
"sudo-ai/zero123plus-v1.2",
|
| 99 |
custom_pipeline="sudo-ai/zero123plus-pipeline",
|
| 100 |
torch_dtype=torch.float16,
|
| 101 |
-
cache_dir="ckpts/",
|
| 102 |
)
|
| 103 |
pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
| 104 |
pipeline.scheduler.config, timestep_spacing='trailing'
|
| 105 |
)
|
| 106 |
self.zero123plus_v12 = pipeline.to(device)
|
| 107 |
|
|
|
|
| 108 |
pipeline = HunYuan3D_MVD_Std_Pipeline.from_pretrained(
|
| 109 |
-
'
|
| 110 |
torch_dtype=torch.float16,
|
| 111 |
use_safetensors=True,
|
| 112 |
)
|
|
@@ -114,7 +112,7 @@ class FreeSplatterRunner:
|
|
| 114 |
|
| 115 |
# freesplatter
|
| 116 |
config_file = 'configs/freesplatter-object.yaml'
|
| 117 |
-
ckpt_path = hf_hub_download('TencentARC/FreeSplatter', repo_type='model', filename='freesplatter-object.safetensors'
|
| 118 |
model = instantiate_from_config(OmegaConf.load(config_file).model)
|
| 119 |
state_dict = {}
|
| 120 |
with safe_open(ckpt_path, framework="pt", device="cpu") as f:
|
|
@@ -124,7 +122,7 @@ class FreeSplatterRunner:
|
|
| 124 |
self.freesplatter = model.eval().to(device)
|
| 125 |
|
| 126 |
config_file = 'configs/freesplatter-object-2dgs.yaml'
|
| 127 |
-
ckpt_path = hf_hub_download('TencentARC/FreeSplatter', repo_type='model', filename='freesplatter-object-2dgs.safetensors'
|
| 128 |
model = instantiate_from_config(OmegaConf.load(config_file).model)
|
| 129 |
state_dict = {}
|
| 130 |
with safe_open(ckpt_path, framework="pt", device="cpu") as f:
|
|
@@ -134,7 +132,7 @@ class FreeSplatterRunner:
|
|
| 134 |
self.freesplatter_2dgs = model.eval().to(device)
|
| 135 |
|
| 136 |
config_file = 'configs/freesplatter-scene.yaml'
|
| 137 |
-
ckpt_path = hf_hub_download('TencentARC/FreeSplatter', repo_type='model', filename='freesplatter-scene.safetensors'
|
| 138 |
model = instantiate_from_config(OmegaConf.load(config_file).model)
|
| 139 |
state_dict = {}
|
| 140 |
with safe_open(ckpt_path, framework="pt", device="cpu") as f:
|
|
|
|
| 16 |
from einops import rearrange
|
| 17 |
from scipy.spatial.transform import Rotation
|
| 18 |
from safetensors import safe_open
|
| 19 |
+
from huggingface_hub import hf_hub_download, snapshot_download
|
| 20 |
|
| 21 |
from transformers import AutoModelForImageSegmentation
|
| 22 |
from diffusers import DiffusionPipeline, EulerAncestralDiscreteScheduler
|
|
|
|
| 78 |
self.rembg = AutoModelForImageSegmentation.from_pretrained(
|
| 79 |
"briaai/RMBG-2.0",
|
| 80 |
trust_remote_code=True,
|
|
|
|
| 81 |
)
|
| 82 |
self.rembg.eval()
|
| 83 |
|
|
|
|
| 86 |
"sudo-ai/zero123plus-v1.1",
|
| 87 |
custom_pipeline="sudo-ai/zero123plus-pipeline",
|
| 88 |
torch_dtype=torch.float16,
|
|
|
|
| 89 |
)
|
| 90 |
pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
| 91 |
pipeline.scheduler.config, timestep_spacing='trailing'
|
|
|
|
| 96 |
"sudo-ai/zero123plus-v1.2",
|
| 97 |
custom_pipeline="sudo-ai/zero123plus-pipeline",
|
| 98 |
torch_dtype=torch.float16,
|
|
|
|
| 99 |
)
|
| 100 |
pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
| 101 |
pipeline.scheduler.config, timestep_spacing='trailing'
|
| 102 |
)
|
| 103 |
self.zero123plus_v12 = pipeline.to(device)
|
| 104 |
|
| 105 |
+
download_dir = snapshot_download('tencent/Hunyuan3D-1', repo_type='model')
|
| 106 |
pipeline = HunYuan3D_MVD_Std_Pipeline.from_pretrained(
|
| 107 |
+
os.path.join(download_dir, 'mvd_std'),
|
| 108 |
torch_dtype=torch.float16,
|
| 109 |
use_safetensors=True,
|
| 110 |
)
|
|
|
|
| 112 |
|
| 113 |
# freesplatter
|
| 114 |
config_file = 'configs/freesplatter-object.yaml'
|
| 115 |
+
ckpt_path = hf_hub_download('TencentARC/FreeSplatter', repo_type='model', filename='freesplatter-object.safetensors')
|
| 116 |
model = instantiate_from_config(OmegaConf.load(config_file).model)
|
| 117 |
state_dict = {}
|
| 118 |
with safe_open(ckpt_path, framework="pt", device="cpu") as f:
|
|
|
|
| 122 |
self.freesplatter = model.eval().to(device)
|
| 123 |
|
| 124 |
config_file = 'configs/freesplatter-object-2dgs.yaml'
|
| 125 |
+
ckpt_path = hf_hub_download('TencentARC/FreeSplatter', repo_type='model', filename='freesplatter-object-2dgs.safetensors')
|
| 126 |
model = instantiate_from_config(OmegaConf.load(config_file).model)
|
| 127 |
state_dict = {}
|
| 128 |
with safe_open(ckpt_path, framework="pt", device="cpu") as f:
|
|
|
|
| 132 |
self.freesplatter_2dgs = model.eval().to(device)
|
| 133 |
|
| 134 |
config_file = 'configs/freesplatter-scene.yaml'
|
| 135 |
+
ckpt_path = hf_hub_download('TencentARC/FreeSplatter', repo_type='model', filename='freesplatter-scene.safetensors')
|
| 136 |
model = instantiate_from_config(OmegaConf.load(config_file).model)
|
| 137 |
state_dict = {}
|
| 138 |
with safe_open(ckpt_path, framework="pt", device="cpu") as f:
|