Spaces:
Running
on
L40S
Running
on
L40S
Update app.py
Browse files
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 |
-
|
|
|
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 |
try:
|
366 |
-
#
|
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:
|