aiqtech commited on
Commit
b8b59c5
ยท
verified ยท
1 Parent(s): c201c52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -5
app.py CHANGED
@@ -332,11 +332,53 @@ def move_to_device(model, device):
332
 
333
  @spaces.GPU
334
  def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[str, str]:
335
- gs, mesh, trial_id = unpack_state(state)
336
- glb = postprocessing_utils.to_glb(gs, mesh, simplify=mesh_simplify, texture_size=texture_size, verbose=False)
337
- glb_path = f"{TMP_DIR}/{trial_id}.glb"
338
- glb.export(glb_path)
339
- return glb_path, glb_path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
 
341
 
342
  def activate_button() -> gr.Button:
 
332
 
333
  @spaces.GPU
334
  def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[str, str]:
335
+ try:
336
+ # GPU ๋ฉ”๋ชจ๋ฆฌ ์ •๋ฆฌ
337
+ clear_gpu_memory()
338
+
339
+ # ์ƒํƒœ ์–ธํŒจํ‚น
340
+ gs, mesh, trial_id = unpack_state(state)
341
+
342
+ # GLB ๋ณ€ํ™˜ ์ „ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ
343
+ if gs is None or mesh is None:
344
+ print("Error: Invalid gaussian or mesh data")
345
+ return None, None
346
+
347
+ # GLB ๋ณ€ํ™˜
348
+ with torch.inference_mode():
349
+ glb = postprocessing_utils.to_glb(
350
+ gs,
351
+ mesh,
352
+ simplify=mesh_simplify,
353
+ texture_size=texture_size,
354
+ verbose=True # ๋””๋ฒ„๊น…์„ ์œ„ํ•ด verbose ๋ชจ๋“œ ํ™œ์„ฑํ™”
355
+ )
356
+
357
+ if glb is None:
358
+ print("Error: GLB conversion failed")
359
+ return None, None
360
+
361
+ # ํŒŒ์ผ ์ €์žฅ
362
+ glb_path = f"{TMP_DIR}/{trial_id}.glb"
363
+ try:
364
+ glb.export(glb_path)
365
+ if not os.path.exists(glb_path):
366
+ print(f"Error: GLB file was not created at {glb_path}")
367
+ return None, None
368
+ except Exception as e:
369
+ print(f"Error saving GLB file: {str(e)}")
370
+ return None, None
371
+
372
+ print(f"Successfully created GLB file at: {glb_path}")
373
+ return glb_path, glb_path
374
+
375
+ except Exception as e:
376
+ print(f"Error in extract_glb: {str(e)}")
377
+ return None, None
378
+
379
+ finally:
380
+ # ์ •๋ฆฌ ์ž‘์—…
381
+ clear_gpu_memory()
382
 
383
 
384
  def activate_button() -> gr.Button: