Spaces:
Sleeping
Sleeping
staswrs
commited on
Commit
·
d23c9df
1
Parent(s):
cf54aef
clean scene 1
Browse files
app.py
CHANGED
|
@@ -20,6 +20,7 @@ import torch
|
|
| 20 |
import zipfile
|
| 21 |
import requests
|
| 22 |
import traceback
|
|
|
|
| 23 |
|
| 24 |
from inference_triposg import run_triposg
|
| 25 |
from triposg.pipelines.pipeline_triposg import TripoSGPipeline
|
|
@@ -97,29 +98,43 @@ def generate(image_path, face_number=50000, guidance_scale=5.0, num_steps=25):
|
|
| 97 |
# return output_path if os.path.exists(output_path) else "Error: output file not found"
|
| 98 |
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
if mesh is None:
|
| 101 |
-
raise ValueError("Mesh generation
|
| 102 |
|
| 103 |
-
#
|
| 104 |
-
mesh.visual = None
|
| 105 |
mesh.metadata.clear()
|
| 106 |
-
mesh.name = "
|
| 107 |
|
| 108 |
-
# Экспорт
|
| 109 |
glb_data = mesh.export(file_type="glb")
|
| 110 |
with open(output_path, "wb") as f:
|
| 111 |
f.write(glb_data)
|
| 112 |
|
| 113 |
print(f"[DEBUG] Mesh saved to {output_path}")
|
| 114 |
-
|
| 115 |
-
return output_path if os.path.exists(output_path) else "Error: output file not found"
|
| 116 |
-
|
| 117 |
-
|
| 118 |
# except Exception as e:
|
| 119 |
# print("[ERROR]", e)
|
| 120 |
# return f"Error: {e}"
|
| 121 |
except Exception as e:
|
| 122 |
-
import traceback
|
| 123 |
print("[ERROR]", e)
|
| 124 |
traceback.print_exc() # ← выведет полную трассировку в логи
|
| 125 |
return f"Error: {e}"
|
|
|
|
| 20 |
import zipfile
|
| 21 |
import requests
|
| 22 |
import traceback
|
| 23 |
+
import trimesh
|
| 24 |
|
| 25 |
from inference_triposg import run_triposg
|
| 26 |
from triposg.pipelines.pipeline_triposg import TripoSGPipeline
|
|
|
|
| 98 |
# return output_path if os.path.exists(output_path) else "Error: output file not found"
|
| 99 |
|
| 100 |
|
| 101 |
+
# if mesh is None:
|
| 102 |
+
# raise ValueError("Mesh generation failed")
|
| 103 |
+
|
| 104 |
+
# # Убираем визуал, метаданные, обертки
|
| 105 |
+
# mesh.visual = None
|
| 106 |
+
# mesh.metadata.clear()
|
| 107 |
+
# mesh.name = "endless_tools"
|
| 108 |
+
|
| 109 |
+
# # Экспорт только геометрии
|
| 110 |
+
# glb_data = mesh.export(file_type="glb")
|
| 111 |
+
# with open(output_path, "wb") as f:
|
| 112 |
+
# f.write(glb_data)
|
| 113 |
+
|
| 114 |
+
# print(f"[DEBUG] Mesh saved to {output_path}")
|
| 115 |
+
|
| 116 |
+
# return output_path if os.path.exists(output_path) else "Error: output file not found"
|
| 117 |
+
|
| 118 |
if mesh is None:
|
| 119 |
+
raise ValueError("Mesh generation returned None")
|
| 120 |
|
| 121 |
+
# Очистка визуала, метаданных и имени
|
| 122 |
+
mesh.visual = trimesh.visual.ColorVisuals(mesh=mesh, vertex_colors=None)
|
| 123 |
mesh.metadata.clear()
|
| 124 |
+
mesh.name = "geometry_0"
|
| 125 |
|
| 126 |
+
# Экспорт .glb вручную (иначе Trimesh добавляет сцену)
|
| 127 |
glb_data = mesh.export(file_type="glb")
|
| 128 |
with open(output_path, "wb") as f:
|
| 129 |
f.write(glb_data)
|
| 130 |
|
| 131 |
print(f"[DEBUG] Mesh saved to {output_path}")
|
| 132 |
+
return output_path if os.path.exists(output_path) else None
|
|
|
|
|
|
|
|
|
|
| 133 |
# except Exception as e:
|
| 134 |
# print("[ERROR]", e)
|
| 135 |
# return f"Error: {e}"
|
| 136 |
except Exception as e:
|
| 137 |
+
# import traceback
|
| 138 |
print("[ERROR]", e)
|
| 139 |
traceback.print_exc() # ← выведет полную трассировку в логи
|
| 140 |
return f"Error: {e}"
|