Upload example/demo.py
Browse files- example/demo.py +48 -0
example/demo.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
One-click demo: creates a synthetic sphere point cloud and runs the full pipeline.
|
| 3 |
+
Perfect for beginners who want to see it work immediately.
|
| 4 |
+
|
| 5 |
+
Usage:
|
| 6 |
+
python example/demo.py
|
| 7 |
+
"""
|
| 8 |
+
import subprocess
|
| 9 |
+
import sys
|
| 10 |
+
import os
|
| 11 |
+
|
| 12 |
+
# 1. Generate synthetic data
|
| 13 |
+
print("=" * 60)
|
| 14 |
+
print("Step 1: Creating a synthetic sphere point cloud...")
|
| 15 |
+
print("=" * 60)
|
| 16 |
+
result = subprocess.run([sys.executable, os.path.join(os.path.dirname(__file__), "make_sphere.py")])
|
| 17 |
+
if result.returncode != 0:
|
| 18 |
+
print("Failed to generate sphere. Aborting.")
|
| 19 |
+
sys.exit(1)
|
| 20 |
+
|
| 21 |
+
# 2. Run the pipeline with reduced iterations for speed
|
| 22 |
+
print("\n" + "=" * 60)
|
| 23 |
+
print("Step 2: Running LightweightMR (reduced quality for speed)...")
|
| 24 |
+
print(" This will take ~5–15 minutes on CPU, ~1 minute on GPU.")
|
| 25 |
+
print("=" * 60)
|
| 26 |
+
cmd = [
|
| 27 |
+
sys.executable, "-m", "lightweightmr",
|
| 28 |
+
"-i", "example/sphere.ply",
|
| 29 |
+
"-o", "example/sphere_mesh.ply",
|
| 30 |
+
"--device", "cpu",
|
| 31 |
+
"--sdf-iters", "5000",
|
| 32 |
+
"--vg-iters", "2000",
|
| 33 |
+
"--vertices", "800",
|
| 34 |
+
]
|
| 35 |
+
print(f"Command: {' '.join(cmd)}\n")
|
| 36 |
+
result = subprocess.run(cmd)
|
| 37 |
+
if result.returncode != 0:
|
| 38 |
+
print("Pipeline failed. See error above.")
|
| 39 |
+
sys.exit(1)
|
| 40 |
+
|
| 41 |
+
print("\n" + "=" * 60)
|
| 42 |
+
print("SUCCESS!")
|
| 43 |
+
print("=" * 60)
|
| 44 |
+
print(f" Input: example/sphere.ply")
|
| 45 |
+
print(f" Output: example/sphere_mesh.ply")
|
| 46 |
+
print("\nOpen the mesh in Blender, MeshLab, or Windows 3D Viewer.")
|
| 47 |
+
print("For better quality, re-run with more iterations:")
|
| 48 |
+
print(" python -m lightweightmr -i example/sphere.ply -o example/sphere_mesh.ply --sdf-iters 20000 --vg-iters 8000 --vertices 3400")
|