Spaces:
Sleeping
Sleeping
Fix: Resolve CUDA and module errors for Hugging Face deployment
Browse files- gradio_app.py +14 -8
gradio_app.py
CHANGED
@@ -50,26 +50,32 @@ from hy3dpaint.convert_utils import create_glb_with_pbr_materials
|
|
50 |
|
51 |
|
52 |
MAX_SEED = 1e7
|
53 |
-
ENV = "
|
54 |
if ENV == 'Huggingface':
|
55 |
"""
|
56 |
Setup environment for running on Huggingface platform.
|
57 |
|
58 |
This block performs the following:
|
|
|
59 |
- Changes directory to the differentiable renderer folder and runs a shell
|
60 |
script to compile the mesh painter.
|
61 |
-
- Installs a custom rasterizer wheel package via pip.
|
62 |
|
63 |
Note:
|
64 |
This setup assumes the script is running in the Huggingface environment
|
65 |
with the specified directory structure.
|
66 |
"""
|
67 |
import os, spaces, subprocess, sys, shlex
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
else:
|
74 |
"""
|
75 |
Define a dummy `spaces` module with a GPU decorator class for local environment.
|
@@ -854,7 +860,7 @@ if __name__ == '__main__':
|
|
854 |
from hy3dshape.pipelines import export_to_trimesh
|
855 |
from hy3dshape.birefnet_rembg import BiRefNetRemover
|
856 |
|
857 |
-
rmbg_worker = BiRefNetRemover()
|
858 |
i23d_worker = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
|
859 |
args.model_path,
|
860 |
subfolder=args.subfolder,
|
|
|
50 |
|
51 |
|
52 |
MAX_SEED = 1e7
|
53 |
+
ENV = "Huggingface" # "Huggingface"
|
54 |
if ENV == 'Huggingface':
|
55 |
"""
|
56 |
Setup environment for running on Huggingface platform.
|
57 |
|
58 |
This block performs the following:
|
59 |
+
- Installs the custom_rasterizer package.
|
60 |
- Changes directory to the differentiable renderer folder and runs a shell
|
61 |
script to compile the mesh painter.
|
|
|
62 |
|
63 |
Note:
|
64 |
This setup assumes the script is running in the Huggingface environment
|
65 |
with the specified directory structure.
|
66 |
"""
|
67 |
import os, spaces, subprocess, sys, shlex
|
68 |
+
|
69 |
+
print("Installing custom_rasterizer...")
|
70 |
+
subprocess.run(
|
71 |
+
shlex.split("pip install -e ./hy3dpaint/custom_rasterizer"),
|
72 |
+
check=True
|
73 |
+
)
|
74 |
+
|
75 |
+
print("Compiling mesh_painter...")
|
76 |
+
os.system("cd ./hy3dpaint/DifferentiableRenderer && bash compile_mesh_painter.sh")
|
77 |
+
print("Finished compilation.")
|
78 |
+
|
79 |
else:
|
80 |
"""
|
81 |
Define a dummy `spaces` module with a GPU decorator class for local environment.
|
|
|
860 |
from hy3dshape.pipelines import export_to_trimesh
|
861 |
from hy3dshape.birefnet_rembg import BiRefNetRemover
|
862 |
|
863 |
+
rmbg_worker = BiRefNetRemover(device=args.device)
|
864 |
i23d_worker = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
|
865 |
args.model_path,
|
866 |
subfolder=args.subfolder,
|