Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
|
|
|
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.
|
361 |
if hasattr(mesh, 'faces') and torch.is_tensor(mesh.faces):
|
362 |
-
mesh.faces = mesh.faces.
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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")
|