Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
#
|
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")
|