aiqtech commited on
Commit
3e2e399
Β·
verified Β·
1 Parent(s): 9d0a3f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -27
app.py CHANGED
@@ -347,44 +347,28 @@ def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[s
347
  # GLB λ³€ν™˜
348
  with torch.inference_mode():
349
  try:
350
- # Gaussian ν…μ„œλ“€μ„ float32둜 λ³€ν™˜ν•˜κ³  requires_grad μ„€μ •
351
  for attr_name in ['_xyz', '_features_dc', '_scaling', '_rotation', '_opacity']:
352
  if hasattr(gs, attr_name):
353
  tensor = getattr(gs, attr_name)
354
  if torch.is_tensor(tensor):
355
- # float32둜 λ³€ν™˜ν•˜κ³  requires_grad μ„€μ •
356
- new_tensor = tensor.clone().detach().float().requires_grad_(True)
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.clone().detach().float().requires_grad_(True)
362
  if hasattr(mesh, 'faces') and torch.is_tensor(mesh.faces):
363
- mesh.faces = mesh.faces.clone().detach().long() # facesλŠ” μ •μˆ˜ν˜• μœ μ§€
364
 
365
  # GLB λ³€ν™˜ μ‹œλ„
366
- try:
367
- # ν…μŠ€μ²˜ 베이킹 μ˜΅μ…˜ μ‘°μ •
368
- glb = postprocessing_utils.to_glb(
369
- gs,
370
- mesh,
371
- simplify=mesh_simplify,
372
- texture_size=texture_size,
373
- verbose=True,
374
- bake_texture=True, # ν…μŠ€μ²˜ 베이킹 ν™œμ„±ν™”
375
- bake_sample_count=100, # μƒ˜ν”Œλ§ 수 μ‘°μ •
376
- bake_resolution=1024 # 베이킹 해상도 μ„€μ •
377
- )
378
- except Exception as e:
379
- print(f"First GLB conversion attempt failed: {str(e)}")
380
- # κ°„λ‹¨ν•œ μ„€μ •μœΌλ‘œ λ‹€μ‹œ μ‹œλ„
381
- glb = postprocessing_utils.to_glb(
382
- gs,
383
- mesh,
384
- simplify=mesh_simplify,
385
- texture_size=texture_size,
386
- bake_texture=False # ν…μŠ€μ²˜ 베이킹 λΉ„ν™œμ„±ν™”
387
- )
388
 
389
  except Exception as e:
390
  print(f"Error during GLB conversion: {str(e)}")
 
347
  # GLB λ³€ν™˜
348
  with torch.inference_mode():
349
  try:
350
+ # Gaussian ν…μ„œλ“€μ„ float32둜 λ³€ν™˜
351
  for attr_name in ['_xyz', '_features_dc', '_scaling', '_rotation', '_opacity']:
352
  if hasattr(gs, attr_name):
353
  tensor = getattr(gs, attr_name)
354
  if torch.is_tensor(tensor):
355
+ new_tensor = tensor.clone().detach().float()
 
356
  setattr(gs, attr_name, new_tensor)
357
 
358
  # Mesh ν…μ„œλ“€μ„ λ³€ν™˜
359
  if hasattr(mesh, 'vertices') and torch.is_tensor(mesh.vertices):
360
+ mesh.vertices = mesh.vertices.clone().detach().float()
361
  if hasattr(mesh, 'faces') and torch.is_tensor(mesh.faces):
362
+ mesh.faces = mesh.faces.clone().detach().long()
363
 
364
  # GLB λ³€ν™˜ μ‹œλ„
365
+ glb = postprocessing_utils.to_glb(
366
+ gs,
367
+ mesh,
368
+ simplify=mesh_simplify,
369
+ texture_size=texture_size,
370
+ verbose=True
371
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
 
373
  except Exception as e:
374
  print(f"Error during GLB conversion: {str(e)}")