Spaces:
Running
on
Zero
Running
on
Zero
demo
Browse files
app.py
CHANGED
|
@@ -50,11 +50,6 @@ import sys
|
|
| 50 |
OUTPUTS_DIR = Path.cwd() / "outputs"
|
| 51 |
OUTPUTS_DIR.mkdir(exist_ok=True)
|
| 52 |
|
| 53 |
-
def _as_str_path(p):
|
| 54 |
-
"""Coerce any Path-like to a plain string for Gradio components."""
|
| 55 |
-
from pathlib import Path as _Path
|
| 56 |
-
return str(p) if isinstance(p, (str, _Path)) else ""
|
| 57 |
-
|
| 58 |
def _log_viewer_file(ply_path: Path):
|
| 59 |
"""Print a concise JSON line about the viewer file so users can debug from Space logs."""
|
| 60 |
info = {
|
|
@@ -366,12 +361,12 @@ class FaceLiftPipeline:
|
|
| 366 |
# Final CUDA cache clear
|
| 367 |
torch.cuda.empty_cache()
|
| 368 |
|
| 369 |
-
# Return
|
| 370 |
return (
|
| 371 |
str(output_path), # Reconstruction grid
|
| 372 |
str(turntable_path), # Turntable video
|
| 373 |
-
|
| 374 |
-
|
| 375 |
)
|
| 376 |
|
| 377 |
except Exception as e:
|
|
@@ -428,23 +423,8 @@ def main():
|
|
| 428 |
out_ply = gr.File(label="Download 3D Model (.ply)")
|
| 429 |
|
| 430 |
# Wrapper: call the pipeline and forward outputs in the exact order expected
|
| 431 |
-
@spaces.GPU(duration=1) # trivial; only formats outputs
|
| 432 |
def _generate_and_filter_outputs(image_path, auto_crop, guidance_scale, random_seed, num_steps):
|
| 433 |
-
(
|
| 434 |
-
output_path,
|
| 435 |
-
turntable_path,
|
| 436 |
-
viewer_update,
|
| 437 |
-
ply_dl_path,
|
| 438 |
-
) = pipeline.generate_3d_head(image_path, auto_crop, guidance_scale, random_seed, num_steps)
|
| 439 |
-
# Ensure correct types for each component
|
| 440 |
-
if not isinstance(viewer_update, gr.components.Model3D.Update):
|
| 441 |
-
viewer_update = gr.Model3D.update(value=_as_str_path(viewer_update))
|
| 442 |
-
return (
|
| 443 |
-
_as_str_path(output_path),
|
| 444 |
-
_as_str_path(turntable_path),
|
| 445 |
-
viewer_update,
|
| 446 |
-
_as_str_path(ply_dl_path),
|
| 447 |
-
)
|
| 448 |
|
| 449 |
# Run generation and display all outputs
|
| 450 |
run_btn.click(
|
|
@@ -457,7 +437,7 @@ def main():
|
|
| 457 |
def _load_sample_viewer():
|
| 458 |
sample_path = _write_sample_cube_ply(Path("outputs") / "sample_cube.ply")
|
| 459 |
print("[VIEWER-SAMPLE]", os.path.abspath(sample_path))
|
| 460 |
-
return
|
| 461 |
|
| 462 |
sample_btn.click(_load_sample_viewer, inputs=[], outputs=[out_viewer])
|
| 463 |
|
|
|
|
| 50 |
OUTPUTS_DIR = Path.cwd() / "outputs"
|
| 51 |
OUTPUTS_DIR.mkdir(exist_ok=True)
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
def _log_viewer_file(ply_path: Path):
|
| 54 |
"""Print a concise JSON line about the viewer file so users can debug from Space logs."""
|
| 55 |
info = {
|
|
|
|
| 361 |
# Final CUDA cache clear
|
| 362 |
torch.cuda.empty_cache()
|
| 363 |
|
| 364 |
+
# Return paths directly (Gradio components handle them automatically)
|
| 365 |
return (
|
| 366 |
str(output_path), # Reconstruction grid
|
| 367 |
str(turntable_path), # Turntable video
|
| 368 |
+
str(ply_path), # Viewer
|
| 369 |
+
str(ply_path), # Download file
|
| 370 |
)
|
| 371 |
|
| 372 |
except Exception as e:
|
|
|
|
| 423 |
out_ply = gr.File(label="Download 3D Model (.ply)")
|
| 424 |
|
| 425 |
# Wrapper: call the pipeline and forward outputs in the exact order expected
|
|
|
|
| 426 |
def _generate_and_filter_outputs(image_path, auto_crop, guidance_scale, random_seed, num_steps):
|
| 427 |
+
return pipeline.generate_3d_head(image_path, auto_crop, guidance_scale, random_seed, num_steps)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
|
| 429 |
# Run generation and display all outputs
|
| 430 |
run_btn.click(
|
|
|
|
| 437 |
def _load_sample_viewer():
|
| 438 |
sample_path = _write_sample_cube_ply(Path("outputs") / "sample_cube.ply")
|
| 439 |
print("[VIEWER-SAMPLE]", os.path.abspath(sample_path))
|
| 440 |
+
return sample_path
|
| 441 |
|
| 442 |
sample_btn.click(_load_sample_viewer, inputs=[], outputs=[out_viewer])
|
| 443 |
|