Spaces:
Running
on
Zero
Running
on
Zero
Fixed a variable naming issue that broke the pipeline
Browse files- gradio_app.py +31 -12
gradio_app.py
CHANGED
@@ -208,12 +208,18 @@ def process_generation_job(job_id: str, images: Dict[str, Image.Image], options:
|
|
208 |
update_job_status(job_id, JobStatus.PROCESSING, progress=50, stage="shape_generation")
|
209 |
|
210 |
# After mesh generation and before exporting, print and store stats
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
214 |
|
215 |
# Print generation parameters for traceability
|
216 |
-
|
|
|
|
|
|
|
217 |
|
218 |
# Export white mesh
|
219 |
white_mesh_path = export_mesh(mesh, save_folder, textured=False, type='obj')
|
@@ -231,11 +237,15 @@ def process_generation_job(job_id: str, images: Dict[str, Image.Image], options:
|
|
231 |
try:
|
232 |
text_path = os.path.join(save_folder, 'textured_mesh.obj')
|
233 |
# Use GPU function for texture generation with lazy initialization
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
239 |
|
240 |
# Try texture generation with adaptive settings based on available images
|
241 |
textured_mesh_path = generate_texture_lazy_adaptive(
|
@@ -246,13 +256,19 @@ def process_generation_job(job_id: str, images: Dict[str, Image.Image], options:
|
|
246 |
)
|
247 |
|
248 |
if textured_mesh_path and os.path.exists(textured_mesh_path):
|
249 |
-
|
|
|
|
|
|
|
250 |
# Convert to GLB
|
251 |
glb_path_textured = os.path.join(save_folder, 'textured_mesh.glb')
|
252 |
quick_convert_with_obj2gltf(textured_mesh_path, glb_path_textured)
|
253 |
textured_mesh_path = glb_path_textured
|
254 |
else:
|
255 |
-
|
|
|
|
|
|
|
256 |
textured_mesh_path = None
|
257 |
|
258 |
except Exception as e:
|
@@ -260,7 +276,10 @@ def process_generation_job(job_id: str, images: Dict[str, Image.Image], options:
|
|
260 |
# Continue without texture - user will get the white mesh
|
261 |
textured_mesh_path = None
|
262 |
else:
|
263 |
-
|
|
|
|
|
|
|
264 |
update_job_status(job_id, JobStatus.PROCESSING, progress=75, stage="texture_generation_unavailable",
|
265 |
message="Texture generation is not available - returning mesh without texture")
|
266 |
|
|
|
208 |
update_job_status(job_id, JobStatus.PROCESSING, progress=50, stage="shape_generation")
|
209 |
|
210 |
# After mesh generation and before exporting, print and store stats
|
211 |
+
try:
|
212 |
+
number_of_faces = mesh.faces.shape[0] if hasattr(mesh, 'faces') else None
|
213 |
+
number_of_vertices = mesh.vertices.shape[0] if hasattr(mesh, 'vertices') else None
|
214 |
+
logger.info(f"Mesh stats: faces={number_of_faces}, vertices={number_of_vertices}")
|
215 |
+
except Exception as e:
|
216 |
+
logger.warning(f"Failed to log mesh stats: {e}")
|
217 |
|
218 |
# Print generation parameters for traceability
|
219 |
+
try:
|
220 |
+
logger.info(f"Generation parameters: seed={seed}, steps=75, octree_resolution=384, guidance_scale=9.0, num_chunks=200000, target_face_count=15000")
|
221 |
+
except Exception as e:
|
222 |
+
logger.warning(f"Failed to log generation parameters: {e}")
|
223 |
|
224 |
# Export white mesh
|
225 |
white_mesh_path = export_mesh(mesh, save_folder, textured=False, type='obj')
|
|
|
237 |
try:
|
238 |
text_path = os.path.join(save_folder, 'textured_mesh.obj')
|
239 |
# Use GPU function for texture generation with lazy initialization
|
240 |
+
try:
|
241 |
+
logger.info(f"Starting texture generation for job {job_id}")
|
242 |
+
|
243 |
+
# Count available images to adapt texture generation settings
|
244 |
+
num_images = len(pil_images)
|
245 |
+
logger.info(f"Job {job_id} has {num_images} images available")
|
246 |
+
except Exception as e:
|
247 |
+
logger.warning(f"Failed to log texture generation start: {e}")
|
248 |
+
num_images = len(pil_images) if pil_images else 1
|
249 |
|
250 |
# Try texture generation with adaptive settings based on available images
|
251 |
textured_mesh_path = generate_texture_lazy_adaptive(
|
|
|
256 |
)
|
257 |
|
258 |
if textured_mesh_path and os.path.exists(textured_mesh_path):
|
259 |
+
try:
|
260 |
+
logger.info(f"Texture generation completed for job {job_id}")
|
261 |
+
except Exception as e:
|
262 |
+
logger.warning(f"Failed to log texture completion: {e}")
|
263 |
# Convert to GLB
|
264 |
glb_path_textured = os.path.join(save_folder, 'textured_mesh.glb')
|
265 |
quick_convert_with_obj2gltf(textured_mesh_path, glb_path_textured)
|
266 |
textured_mesh_path = glb_path_textured
|
267 |
else:
|
268 |
+
try:
|
269 |
+
logger.warning(f"Texture generation returned None or file doesn't exist for job {job_id}")
|
270 |
+
except Exception as e:
|
271 |
+
logger.warning(f"Failed to log texture warning: {e}")
|
272 |
textured_mesh_path = None
|
273 |
|
274 |
except Exception as e:
|
|
|
276 |
# Continue without texture - user will get the white mesh
|
277 |
textured_mesh_path = None
|
278 |
else:
|
279 |
+
try:
|
280 |
+
logger.warning(f"Texture generation requested for job {job_id} but texture pipeline is not available")
|
281 |
+
except Exception as e:
|
282 |
+
logger.warning(f"Failed to log texture unavailable warning: {e}")
|
283 |
update_job_status(job_id, JobStatus.PROCESSING, progress=75, stage="texture_generation_unavailable",
|
284 |
message="Texture generation is not available - returning mesh without texture")
|
285 |
|