aiqtech commited on
Commit
4970f9d
Β·
verified Β·
1 Parent(s): 3e2e399

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -352,14 +352,15 @@ 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
- 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(
@@ -367,12 +368,27 @@ def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[s
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)}")
375
- return None, None
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
  if glb is None:
378
  print("Error: GLB conversion failed")
 
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(
 
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")