aiqtech commited on
Commit
9d0a3f6
Β·
verified Β·
1 Parent(s): 304a9b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -347,29 +347,33 @@ 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둜 λ³€ν™˜
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 ν…μ„œλ“€μ„ float32둜 λ³€ν™˜
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
  try:
366
- # optimize_uv λ§€κ°œλ³€μˆ˜ 제거
367
  glb = postprocessing_utils.to_glb(
368
  gs,
369
  mesh,
370
  simplify=mesh_simplify,
371
  texture_size=texture_size,
372
- verbose=True
 
 
 
373
  )
374
  except Exception as e:
375
  print(f"First GLB conversion attempt failed: {str(e)}")
@@ -378,7 +382,8 @@ def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[s
378
  gs,
379
  mesh,
380
  simplify=mesh_simplify,
381
- texture_size=texture_size
 
382
  )
383
 
384
  except Exception as e:
 
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)}")
 
382
  gs,
383
  mesh,
384
  simplify=mesh_simplify,
385
+ texture_size=texture_size,
386
+ bake_texture=False # ν…μŠ€μ²˜ 베이킹 λΉ„ν™œμ„±ν™”
387
  )
388
 
389
  except Exception as e: