mehdizz commited on
Commit
1a34312
·
verified ·
1 Parent(s): 0ca2001

cancel extract_glb modif

Browse files
Files changed (1) hide show
  1. app.py +14 -6
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
- # Save the GLB file to an absolute path
176
- glb_path_absolute = os.path.join(user_dir, 'sample.glb')
177
- glb.export(glb_path_absolute)
178
  torch.cuda.empty_cache()
179
- # Compute a relative path that Gradio can serve, e.g. "tmp/<session_hash>/sample.glb"
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