Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -347,22 +347,36 @@ def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[s
|
|
347 |
# GLB λ³ν
|
348 |
with torch.inference_mode():
|
349 |
try:
|
350 |
-
#
|
|
|
|
|
|
|
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 |
-
|
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().
|
362 |
if hasattr(mesh, 'faces') and torch.is_tensor(mesh.faces):
|
363 |
-
mesh.faces = mesh.faces.detach().clone().long().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
|
365 |
-
#
|
366 |
glb = postprocessing_utils.to_glb(
|
367 |
gs,
|
368 |
mesh,
|
@@ -373,6 +387,11 @@ def extract_glb(state: dict, mesh_simplify: float, texture_size: int) -> Tuple[s
|
|
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:
|
|
|
347 |
# GLB λ³ν
|
348 |
with torch.inference_mode():
|
349 |
try:
|
350 |
+
# λͺ¨λ ν
μλ₯Ό CUDAλ‘ μ΄λ
|
351 |
+
device = torch.device('cuda:0')
|
352 |
+
|
353 |
+
# Gaussian ν
μλ€μ λ³ν
|
354 |
for attr_name in ['_xyz', '_features_dc', '_scaling', '_rotation', '_opacity']:
|
355 |
if hasattr(gs, attr_name):
|
356 |
tensor = getattr(gs, attr_name)
|
357 |
if torch.is_tensor(tensor):
|
358 |
+
new_tensor = tensor.detach().clone().float().to(device)
|
|
|
359 |
setattr(gs, attr_name, new_tensor)
|
360 |
|
361 |
# Mesh ν
μλ€μ λ³ν
|
362 |
if hasattr(mesh, 'vertices') and torch.is_tensor(mesh.vertices):
|
363 |
+
mesh.vertices = mesh.vertices.detach().clone().float().to(device)
|
364 |
if hasattr(mesh, 'faces') and torch.is_tensor(mesh.faces):
|
365 |
+
mesh.faces = mesh.faces.detach().clone().long().to(device)
|
366 |
+
|
367 |
+
# μΆκ° μμ± νμΈ λ° λ³ν
|
368 |
+
for attr_name in dir(mesh):
|
369 |
+
if attr_name.startswith('_'):
|
370 |
+
continue
|
371 |
+
attr = getattr(mesh, attr_name)
|
372 |
+
if torch.is_tensor(attr):
|
373 |
+
setattr(mesh, attr_name, attr.to(device))
|
374 |
+
|
375 |
+
print("Device check before GLB conversion:")
|
376 |
+
print(f"Gaussian xyz device: {gs._xyz.device}")
|
377 |
+
print(f"Mesh vertices device: {mesh.vertices.device}")
|
378 |
|
379 |
+
# GLB λ³ν
|
380 |
glb = postprocessing_utils.to_glb(
|
381 |
gs,
|
382 |
mesh,
|
|
|
387 |
|
388 |
except Exception as e:
|
389 |
print(f"Error during GLB conversion: {str(e)}")
|
390 |
+
# λλ°μ΄μ€ μ 보 μΆλ ₯
|
391 |
+
if hasattr(gs, '_xyz'):
|
392 |
+
print(f"Gaussian xyz device: {gs._xyz.device}")
|
393 |
+
if hasattr(mesh, 'vertices'):
|
394 |
+
print(f"Mesh vertices device: {mesh.vertices.device}")
|
395 |
return None, None
|
396 |
|
397 |
if glb is None:
|