Spaces:
Running
on
Zero
Running
on
Zero
cancel extract_glb modif
Browse files
app.py
CHANGED
@@ -168,17 +168,25 @@ def extract_glb(
|
|
168 |
texture_size: int,
|
169 |
req: gr.Request,
|
170 |
) -> Tuple[str, str]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
172 |
os.makedirs(user_dir, exist_ok=True)
|
173 |
gs, mesh = unpack_state(state)
|
174 |
glb = postprocessing_utils.to_glb(gs, mesh, simplify=mesh_simplify, texture_size=texture_size, verbose=False)
|
175 |
-
|
176 |
-
|
177 |
-
glb.export(glb_path_absolute)
|
178 |
torch.cuda.empty_cache()
|
179 |
-
|
180 |
-
relative_path = os.path.join("tmp", str(req.session_hash), "sample.glb")
|
181 |
-
return relative_path, relative_path
|
182 |
|
183 |
|
184 |
|
|
|
168 |
texture_size: int,
|
169 |
req: gr.Request,
|
170 |
) -> Tuple[str, str]:
|
171 |
+
"""
|
172 |
+
Extract a GLB file from the 3D model.
|
173 |
+
|
174 |
+
Args:
|
175 |
+
state (dict): The state of the generated 3D model.
|
176 |
+
mesh_simplify (float): The mesh simplification factor.
|
177 |
+
texture_size (int): The texture resolution.
|
178 |
+
|
179 |
+
Returns:
|
180 |
+
str: The path to the extracted GLB file.
|
181 |
+
"""
|
182 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
183 |
os.makedirs(user_dir, exist_ok=True)
|
184 |
gs, mesh = unpack_state(state)
|
185 |
glb = postprocessing_utils.to_glb(gs, mesh, simplify=mesh_simplify, texture_size=texture_size, verbose=False)
|
186 |
+
glb_path = os.path.join(user_dir, 'sample.glb')
|
187 |
+
glb.export(glb_path)
|
|
|
188 |
torch.cuda.empty_cache()
|
189 |
+
return glb_path, glb_path
|
|
|
|
|
190 |
|
191 |
|
192 |
|