aiqtech commited on
Commit
86e0fd5
Β·
verified Β·
1 Parent(s): 4970f9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -22
app.py CHANGED
@@ -352,43 +352,28 @@ def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[s
352
  if hasattr(gs, attr_name):
353
  tensor = getattr(gs, attr_name)
354
  if torch.is_tensor(tensor):
355
- # detach()λ₯Ό μ‚¬μš©ν•˜μ—¬ gradient 좔적 제거
356
- new_tensor = tensor.detach().clone().float()
357
  setattr(gs, attr_name, new_tensor)
358
 
359
  # Mesh ν…μ„œλ“€μ„ λ³€ν™˜
360
  if hasattr(mesh, 'vertices') and torch.is_tensor(mesh.vertices):
361
- mesh.vertices = mesh.vertices.detach().clone().float()
362
  if hasattr(mesh, 'faces') and torch.is_tensor(mesh.faces):
363
- mesh.faces = mesh.faces.detach().clone().long()
364
 
365
- # GLB λ³€ν™˜ μ‹œλ„
366
  glb = postprocessing_utils.to_glb(
367
  gs,
368
  mesh,
369
  simplify=mesh_simplify,
370
  texture_size=texture_size,
371
- verbose=True,
372
- optimize_uv=True, # UV μ΅œμ ν™” ν™œμ„±ν™”
373
- optimize_uv_iters=100, # UV μ΅œμ ν™” 반볡 횟수
374
- texture_interpolation='linear' # ν…μŠ€μ²˜ 보간 방법
375
  )
376
 
377
  except Exception as e:
378
  print(f"Error during GLB conversion: {str(e)}")
379
- # 더 κ°„λ‹¨ν•œ μ„€μ •μœΌλ‘œ μž¬μ‹œλ„
380
- try:
381
- glb = postprocessing_utils.to_glb(
382
- gs,
383
- mesh,
384
- simplify=mesh_simplify,
385
- texture_size=texture_size,
386
- verbose=True,
387
- optimize_uv=False # UV μ΅œμ ν™” λΉ„ν™œμ„±ν™”
388
- )
389
- except Exception as e2:
390
- print(f"Second attempt failed: {str(e2)}")
391
- return None, None
392
 
393
  if glb is None:
394
  print("Error: GLB conversion failed")
 
352
  if hasattr(gs, attr_name):
353
  tensor = getattr(gs, attr_name)
354
  if torch.is_tensor(tensor):
355
+ # gradient 좔적 제거 및 float32둜 λ³€ν™˜
356
+ new_tensor = tensor.detach().clone().float().cpu()
357
  setattr(gs, attr_name, new_tensor)
358
 
359
  # Mesh ν…μ„œλ“€μ„ λ³€ν™˜
360
  if hasattr(mesh, 'vertices') and torch.is_tensor(mesh.vertices):
361
+ mesh.vertices = mesh.vertices.detach().clone().float().cpu()
362
  if hasattr(mesh, 'faces') and torch.is_tensor(mesh.faces):
363
+ mesh.faces = mesh.faces.detach().clone().long().cpu()
364
 
365
+ # κΈ°λ³Έ μ„€μ •μœΌλ‘œ GLB λ³€ν™˜
366
  glb = postprocessing_utils.to_glb(
367
  gs,
368
  mesh,
369
  simplify=mesh_simplify,
370
  texture_size=texture_size,
371
+ verbose=True
 
 
 
372
  )
373
 
374
  except Exception as e:
375
  print(f"Error during GLB conversion: {str(e)}")
376
+ return None, None
 
 
 
 
 
 
 
 
 
 
 
 
377
 
378
  if glb is None:
379
  print("Error: GLB conversion failed")