Spaces:
Running
on
Zero
Running
on
Zero
os.makedirs(..............., exist_ok=True)
Browse files
app.py
CHANGED
@@ -28,6 +28,7 @@ def start_session(req: gr.Request):
|
|
28 |
|
29 |
def end_session(req: gr.Request):
|
30 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
|
|
31 |
shutil.rmtree(user_dir)
|
32 |
|
33 |
|
@@ -136,6 +137,7 @@ def image_to_3d(
|
|
136 |
str: The path to the video of the 3D model.
|
137 |
"""
|
138 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
|
|
139 |
outputs = pipeline.run(
|
140 |
image,
|
141 |
seed=seed,
|
@@ -154,6 +156,7 @@ def image_to_3d(
|
|
154 |
video_geo = render_utils.render_video(outputs['mesh'][0], num_frames=120)['normal']
|
155 |
video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]
|
156 |
video_path = os.path.join(user_dir, 'sample.mp4')
|
|
|
157 |
imageio.mimsave(video_path, video, fps=15)
|
158 |
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0])
|
159 |
torch.cuda.empty_cache()
|
@@ -179,9 +182,11 @@ def extract_glb(
|
|
179 |
str: The path to the extracted GLB file.
|
180 |
"""
|
181 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
|
|
182 |
gs, mesh = unpack_state(state)
|
183 |
glb = postprocessing_utils.to_glb(gs, mesh, simplify=mesh_simplify, texture_size=texture_size, verbose=False)
|
184 |
glb_path = os.path.join(user_dir, 'sample.glb')
|
|
|
185 |
glb.export(glb_path)
|
186 |
torch.cuda.empty_cache()
|
187 |
return glb_path, glb_path
|
|
|
28 |
|
29 |
def end_session(req: gr.Request):
|
30 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
31 |
+
os.makedirs(user_dir, exist_ok=True)
|
32 |
shutil.rmtree(user_dir)
|
33 |
|
34 |
|
|
|
137 |
str: The path to the video of the 3D model.
|
138 |
"""
|
139 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
140 |
+
os.makedirs(user_dir, exist_ok=True)
|
141 |
outputs = pipeline.run(
|
142 |
image,
|
143 |
seed=seed,
|
|
|
156 |
video_geo = render_utils.render_video(outputs['mesh'][0], num_frames=120)['normal']
|
157 |
video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]
|
158 |
video_path = os.path.join(user_dir, 'sample.mp4')
|
159 |
+
os.makedirs(video_path, exist_ok=True)
|
160 |
imageio.mimsave(video_path, video, fps=15)
|
161 |
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0])
|
162 |
torch.cuda.empty_cache()
|
|
|
182 |
str: The path to the extracted GLB file.
|
183 |
"""
|
184 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
185 |
+
os.makedirs(user_dir, exist_ok=True)
|
186 |
gs, mesh = unpack_state(state)
|
187 |
glb = postprocessing_utils.to_glb(gs, mesh, simplify=mesh_simplify, texture_size=texture_size, verbose=False)
|
188 |
glb_path = os.path.join(user_dir, 'sample.glb')
|
189 |
+
os.makedirs(glb_path, exist_ok=True)
|
190 |
glb.export(glb_path)
|
191 |
torch.cuda.empty_cache()
|
192 |
return glb_path, glb_path
|