Spaces:
Running on Zero
Running on Zero
Suppress third-party warnings and add render diagnostics
Browse files
app.py
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_client import Client, handle_file
|
| 3 |
import spaces
|
|
@@ -510,6 +515,14 @@ def image_to_3d(
|
|
| 510 |
images = [image[0] for image in multiimages]
|
| 511 |
processed_images = [preprocess_image(img) for img in images]
|
| 512 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 513 |
# --- Sampling ---
|
| 514 |
outputs, latents = pipeline.run_multi_image(
|
| 515 |
processed_images,
|
|
@@ -545,6 +558,15 @@ def image_to_3d(
|
|
| 545 |
mesh = outputs[0]
|
| 546 |
mesh.simplify(16777216) # nvdiffrast limit
|
| 547 |
images = render_utils.render_snapshot(mesh, resolution=1024, r=2, fov=36, nviews=STEPS, envmap=envmap)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
state = pack_state(latents)
|
| 549 |
torch.cuda.empty_cache()
|
| 550 |
|
|
|
|
| 1 |
+
import warnings
|
| 2 |
+
warnings.filterwarnings("ignore", message=".*torch.distributed.reduce_op.*")
|
| 3 |
+
warnings.filterwarnings("ignore", message=".*torch.cuda.amp.autocast.*")
|
| 4 |
+
warnings.filterwarnings("ignore", message=".*Default grid_sample and affine_grid behavior.*")
|
| 5 |
+
|
| 6 |
import gradio as gr
|
| 7 |
from gradio_client import Client, handle_file
|
| 8 |
import spaces
|
|
|
|
| 515 |
images = [image[0] for image in multiimages]
|
| 516 |
processed_images = [preprocess_image(img) for img in images]
|
| 517 |
|
| 518 |
+
# Debug: save preprocessed images and log stats
|
| 519 |
+
for i, img in enumerate(processed_images):
|
| 520 |
+
arr = np.array(img)
|
| 521 |
+
print(f"[DEBUG] Preprocessed image {i}: mode={img.mode}, size={img.size}, "
|
| 522 |
+
f"dtype={arr.dtype}, min={arr.min()}, max={arr.max()}, mean={arr.mean():.1f}")
|
| 523 |
+
img.save(os.path.join(TMP_DIR, f'debug_preprocessed_{i}.png'))
|
| 524 |
+
print(f"[DEBUG] Pipeline params: mode={multiimage_algo}, tex_mode={tex_multiimage_algo}")
|
| 525 |
+
|
| 526 |
# --- Sampling ---
|
| 527 |
outputs, latents = pipeline.run_multi_image(
|
| 528 |
processed_images,
|
|
|
|
| 558 |
mesh = outputs[0]
|
| 559 |
mesh.simplify(16777216) # nvdiffrast limit
|
| 560 |
images = render_utils.render_snapshot(mesh, resolution=1024, r=2, fov=36, nviews=STEPS, envmap=envmap)
|
| 561 |
+
|
| 562 |
+
# Debug: save base_color render and log stats for all render modes
|
| 563 |
+
for key in images:
|
| 564 |
+
arr = images[key][0] # first view
|
| 565 |
+
print(f"[DEBUG] Render '{key}': shape={arr.shape}, min={arr.min()}, max={arr.max()}, mean={arr.mean():.1f}")
|
| 566 |
+
# Save base_color and shaded_forest for inspection
|
| 567 |
+
Image.fromarray(images['base_color'][0]).save(os.path.join(TMP_DIR, 'debug_base_color.png'))
|
| 568 |
+
Image.fromarray(images['shaded_forest'][0]).save(os.path.join(TMP_DIR, 'debug_shaded_forest.png'))
|
| 569 |
+
|
| 570 |
state = pack_state(latents)
|
| 571 |
torch.cuda.empty_cache()
|
| 572 |
|