Spaces:
Sleeping
Sleeping
Fix: delay spaces import until after GPU functions are defined
Browse files- gradio_app.py +15 -12
gradio_app.py
CHANGED
@@ -57,26 +57,23 @@ if ENV == 'Huggingface':
|
|
57 |
Setup environment for running on Huggingface platform.
|
58 |
|
59 |
This block performs the following:
|
60 |
-
- Installs the custom_rasterizer package.
|
61 |
- Changes directory to the differentiable renderer folder and runs a shell
|
62 |
script to compile the mesh painter.
|
|
|
63 |
|
64 |
Note:
|
65 |
This setup assumes the script is running in the Huggingface environment
|
66 |
with the specified directory structure.
|
67 |
"""
|
68 |
-
import os, subprocess, sys, shlex
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
shlex.split("pip install custom_rasterizer-0.1-cp310-cp310-linux_x86_64.whl"),
|
73 |
-
|
74 |
-
)
|
75 |
-
|
76 |
-
print("Compiling mesh_painter...")
|
77 |
-
os.system("cd ./hy3dpaint/DifferentiableRenderer && bash compile_mesh_painter.sh")
|
78 |
-
print("Finished compilation.")
|
79 |
|
|
|
|
|
80 |
else:
|
81 |
"""
|
82 |
Define a dummy `spaces` module with a GPU decorator class for local environment.
|
@@ -892,4 +889,10 @@ if __name__ == '__main__':
|
|
892 |
torch.cuda.empty_cache()
|
893 |
demo = build_app()
|
894 |
app = gr.mount_gradio_app(app, demo, path="/")
|
|
|
|
|
|
|
|
|
|
|
|
|
895 |
uvicorn.run(app, host=args.host, port=args.port)
|
|
|
57 |
Setup environment for running on Huggingface platform.
|
58 |
|
59 |
This block performs the following:
|
|
|
60 |
- Changes directory to the differentiable renderer folder and runs a shell
|
61 |
script to compile the mesh painter.
|
62 |
+
- Installs a custom rasterizer wheel package via pip.
|
63 |
|
64 |
Note:
|
65 |
This setup assumes the script is running in the Huggingface environment
|
66 |
with the specified directory structure.
|
67 |
"""
|
68 |
+
import os, spaces, subprocess, sys, shlex
|
69 |
+
from spaces import zero
|
70 |
+
|
71 |
+
def prepare_env():
|
72 |
+
subprocess.run(shlex.split("pip install custom_rasterizer-0.1-cp310-cp310-linux_x86_64.whl"), check=True)
|
73 |
+
os.system("cd /home/user/app/hy3dpaint/DifferentiableRenderer && bash compile_mesh_painter.sh")
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
+
prepare_env()
|
76 |
+
|
77 |
else:
|
78 |
"""
|
79 |
Define a dummy `spaces` module with a GPU decorator class for local environment.
|
|
|
889 |
torch.cuda.empty_cache()
|
890 |
demo = build_app()
|
891 |
app = gr.mount_gradio_app(app, demo, path="/")
|
892 |
+
|
893 |
+
if ENV == 'Huggingface':
|
894 |
+
# for Zerogpu
|
895 |
+
from spaces import zero
|
896 |
+
zero.startup()
|
897 |
+
|
898 |
uvicorn.run(app, host=args.host, port=args.port)
|