Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,56 +1,57 @@
|
|
1 |
import shlex
|
2 |
import subprocess
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
shlex.split(
|
8 |
-
"pip install package/onnxruntime_gpu-1.17.0-cp310-cp310-manylinux_2_28_x86_64.whl --force-reinstall --no-deps"
|
9 |
-
), check=True
|
10 |
-
)
|
11 |
-
subprocess.run(
|
12 |
-
shlex.split(
|
13 |
-
"pip install package/nvdiffrast-0.3.1.torch-cp310-cp310-linux_x86_64.whl --force-reinstall --no-deps"
|
14 |
-
), check=True
|
15 |
-
)
|
16 |
-
|
17 |
-
|
18 |
-
if __name__ == "__main__":
|
19 |
-
from huggingface_hub import snapshot_download
|
20 |
-
|
21 |
-
snapshot_download("public-data/Unique3D", repo_type="model", local_dir="./ckpt")
|
22 |
-
|
23 |
-
import os
|
24 |
-
import sys
|
25 |
-
sys.path.append(os.curdir)
|
26 |
-
import torch
|
27 |
-
torch.set_float32_matmul_precision('medium')
|
28 |
-
torch.backends.cuda.matmul.allow_tf32 = True
|
29 |
-
torch.set_grad_enabled(False)
|
30 |
-
|
31 |
import fire
|
32 |
import gradio as gr
|
33 |
from gradio_app.gradio_3dgen import create_ui as create_3d_ui
|
34 |
from gradio_app.all_models import model_zoo
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
'''
|
40 |
|
41 |
def launch():
|
|
|
42 |
model_zoo.init_models()
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
# theme=gr.themes.Monochrome(),
|
47 |
-
) as demo:
|
48 |
with gr.Row():
|
49 |
with gr.Column(scale=1):
|
50 |
gr.Markdown('# ' + _TITLE)
|
51 |
-
|
|
|
|
|
52 |
|
53 |
-
demo.queue().launch(share=True)
|
54 |
-
|
55 |
if __name__ == '__main__':
|
56 |
-
|
|
|
|
|
|
|
|
1 |
import shlex
|
2 |
import subprocess
|
3 |
+
import os
|
4 |
+
import sys
|
5 |
+
from huggingface_hub import snapshot_download
|
6 |
+
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
import fire
|
8 |
import gradio as gr
|
9 |
from gradio_app.gradio_3dgen import create_ui as create_3d_ui
|
10 |
from gradio_app.all_models import model_zoo
|
11 |
|
12 |
+
# Install required packages
|
13 |
+
def setup_dependencies():
|
14 |
+
subprocess.run(shlex.split("pip install pip==24.0"), check=True)
|
15 |
+
subprocess.run(
|
16 |
+
shlex.split(
|
17 |
+
"pip install package/onnxruntime_gpu-1.17.0-cp310-cp310-manylinux_2_28_x86_64.whl --force-reinstall --no-deps"
|
18 |
+
),
|
19 |
+
check=True
|
20 |
+
)
|
21 |
+
subprocess.run(
|
22 |
+
shlex.split(
|
23 |
+
"pip install package/nvdiffrast-0.3.1.torch-cp310-cp310-linux_x86_64.whl --force-reinstall --no-deps"
|
24 |
+
),
|
25 |
+
check=True
|
26 |
+
)
|
27 |
+
|
28 |
+
# Download model checkpoints
|
29 |
+
def setup_model():
|
30 |
+
snapshot_download("public-data/Unique3D", repo_type="model", local_dir="./ckpt")
|
31 |
+
|
32 |
+
# Configure PyTorch settings
|
33 |
+
torch.set_float32_matmul_precision('medium')
|
34 |
+
torch.backends.cuda.matmul.allow_tf32 = True
|
35 |
+
torch.set_grad_enabled(False)
|
36 |
|
37 |
+
# Application title
|
38 |
+
_TITLE = 'Text to 3D'
|
|
|
39 |
|
40 |
def launch():
|
41 |
+
# Initialize models
|
42 |
model_zoo.init_models()
|
43 |
+
|
44 |
+
# Create Gradio interface
|
45 |
+
with gr.Blocks(title=_TITLE) as demo:
|
|
|
|
|
46 |
with gr.Row():
|
47 |
with gr.Column(scale=1):
|
48 |
gr.Markdown('# ' + _TITLE)
|
49 |
+
create_3d_ui("wkl")
|
50 |
+
|
51 |
+
demo.queue().launch(share=True)
|
52 |
|
|
|
|
|
53 |
if __name__ == '__main__':
|
54 |
+
setup_dependencies()
|
55 |
+
setup_model()
|
56 |
+
sys.path.append(os.curdir)
|
57 |
+
fire.Fire(launch)
|