Spaces:
Runtime error
Runtime error
PUM4CH3N
commited on
Commit
·
83d10c9
1
Parent(s):
27271e8
- .gitignore +2 -0
- app.py +23 -27
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.idea/*
|
| 2 |
+
__pycache__
|
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from gradio_litmodel3d import LitModel3D
|
|
| 4 |
|
| 5 |
import os
|
| 6 |
import shutil
|
| 7 |
-
os.environ['TOKENIZERS_PARALLELISM'] = 'true'
|
| 8 |
os.environ['SPCONV_ALGO'] = 'native'
|
| 9 |
from typing import *
|
| 10 |
import torch
|
|
@@ -106,32 +106,28 @@ def text_to_3d(
|
|
| 106 |
dict: The information of the generated 3D model.
|
| 107 |
str: The path to the video of the 3D model.
|
| 108 |
"""
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
return state, video_path
|
| 132 |
-
except Exception as e:
|
| 133 |
-
et, ev, tb = sys.exc_info()
|
| 134 |
-
traceback.print_tb(tb)
|
| 135 |
|
| 136 |
|
| 137 |
@spaces.GPU(duration=90)
|
|
|
|
| 4 |
|
| 5 |
import os
|
| 6 |
import shutil
|
| 7 |
+
# os.environ['TOKENIZERS_PARALLELISM'] = 'true'
|
| 8 |
os.environ['SPCONV_ALGO'] = 'native'
|
| 9 |
from typing import *
|
| 10 |
import torch
|
|
|
|
| 106 |
dict: The information of the generated 3D model.
|
| 107 |
str: The path to the video of the 3D model.
|
| 108 |
"""
|
| 109 |
+
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
| 110 |
+
outputs = pipeline.run(
|
| 111 |
+
prompt,
|
| 112 |
+
seed=seed,
|
| 113 |
+
formats=["gaussian", "mesh"],
|
| 114 |
+
sparse_structure_sampler_params={
|
| 115 |
+
"steps": ss_sampling_steps,
|
| 116 |
+
"cfg_strength": ss_guidance_strength,
|
| 117 |
+
},
|
| 118 |
+
slat_sampler_params={
|
| 119 |
+
"steps": slat_sampling_steps,
|
| 120 |
+
"cfg_strength": slat_guidance_strength,
|
| 121 |
+
},
|
| 122 |
+
)
|
| 123 |
+
video = render_utils.render_video(outputs['gaussian'][0], num_frames=120)['color']
|
| 124 |
+
video_geo = render_utils.render_video(outputs['mesh'][0], num_frames=120)['normal']
|
| 125 |
+
video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]
|
| 126 |
+
video_path = os.path.join(user_dir, 'sample.mp4')
|
| 127 |
+
imageio.mimsave(video_path, video, fps=15)
|
| 128 |
+
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0])
|
| 129 |
+
torch.cuda.empty_cache()
|
| 130 |
+
return state, video_path
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
|
| 133 |
@spaces.GPU(duration=90)
|