Upload 2 files
Browse files
3dgs-to-2dgs-conversion-guide.ipynb
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"},"kaggle":{"accelerator":"none","dataSources":[],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"\n\n# **3DGS to 2DGS Conversion Guide**\n\n\n\n## Main Changes\n\n### 1. Repository Change\n\n* **3DGS**: `https://github.com/graphdeco-inria/gaussian-splatting.git`\n* **2DGS**: `https://github.com/hbb1/2d-gaussian-splatting.git`\n\n### 2. Submodule Change\n\n* **3DGS**: `diff-gaussian-rasterization`\n* **2DGS**: `diff-surfel-rasterization` (for 2D oriented disks)\n\n### 3. Additional Regularization Parameters\n\n2DGS includes the following additional parameters:\n\n* `--lambda_normal`: Hyperparameter for normal consistency.\n* `--lambda_distortion`: Hyperparameter for depth distortion.\n* `--depth_ratio`: 0=mean depth, 1=median depth (default 0 is recommended).\n\n### 4. Improved Mesh Extraction\n\n2DGS supports high-quality mesh extraction:\n\n* Bounded mesh extraction.\n* Unbounded mesh extraction (**New Feature**).\n\n## Code Modification Points\n\n### `setup_environment()` Function\n\n```python\n# Before (3DGS)\nWORK_DIR = \"gaussian-splatting\"\nrun_cmd([\n \"git\", \"clone\", \"--recursive\",\n \"https://github.com/graphdeco-inria/gaussian-splatting.git\",\n WORK_DIR\n])\n\n# After (2DGS)\nWORK_DIR = \"2d-gaussian-splatting\"\nrun_cmd([\n \"git\", \"clone\", \"--recursive\",\n \"https://github.com/hbb1/2d-gaussian-splatting.git\",\n WORK_DIR\n])\n\n```\n\n### Submodule Changes\n\n```python\n# Before (3DGS)\nsubmodules = {\n \"diff-gaussian-rasterization\":\n \"https://github.com/graphdeco-inria/diff-gaussian-rasterization.git\",\n \"simple-knn\":\n \"https://github.com/camenduru/simple-knn.git\"\n}\n\n# After (2DGS)\nsubmodules = {\n \"diff-surfel-rasterization\":\n \"https://github.com/hbb1/diff-surfel-rasterization.git\",\n \"simple-knn\":\n \"https://github.com/camenduru/simple-knn.git\"\n}\n\n```\n\n### `train_gaussian_splatting()` Function\n\n```python\n# Before (3DGS)\ndef train_gaussian_splatting(data_dir, iterations=7000):\n model_path = f\"{WORK_DIR}/output/video\"\n cmd = [\n sys.executable, 'train.py',\n '-s', data_dir,\n '-m', model_path,\n '--iterations', str(iterations),\n '--eval'\n ]\n subprocess.run(cmd, cwd=WORK_DIR, check=True)\n return model_path\n\n# After (2DGS) - Added Regularization Parameters\ndef train_gaussian_splatting(data_dir, iterations=7000, \n lambda_normal=0.05, \n lambda_distortion=0,\n depth_ratio=0):\n \"\"\"\n Training function for 2DGS\n \n Args:\n lambda_normal: Weight for normal consistency (default: 0.05)\n lambda_distortion: Weight for depth distortion (default: 0)\n depth_ratio: 0=mean depth, 1=median depth (default: 0)\n \"\"\"\n model_path = f\"{WORK_DIR}/output/video\"\n cmd = [\n sys.executable, 'train.py',\n '-s', data_dir,\n '-m', model_path,\n '--iterations', str(iterations),\n '--lambda_normal', str(lambda_normal),\n '--lambda_distortion', str(lambda_distortion),\n '--depth_ratio', str(depth_ratio),\n '--eval'\n ]\n subprocess.run(cmd, cwd=WORK_DIR, check=True)\n return model_path\n\n```\n\n### `render_video()` Function\n\n```python\n# Mesh extraction options are added in 2DGS\ndef render_video_and_mesh(model_path, output_video_path, iteration=7000,\n extract_mesh=True, unbounded=False, mesh_res=1024):\n \"\"\"\n Rendering and mesh extraction for 2DGS\n \n Args:\n extract_mesh: Whether to extract mesh\n unbounded: Whether to use unbounded mesh extraction\n mesh_res: Mesh resolution\n \"\"\"\n # Normal rendering\n cmd = [\n sys.executable, 'render.py',\n '-m', model_path,\n '--iteration', str(iteration)\n ]\n \n # Add mesh extraction options\n if extract_mesh:\n if unbounded:\n cmd.extend(['--unbounded', '--mesh_res', str(mesh_res)])\n cmd.extend(['--skip_test', '--skip_train'])\n \n subprocess.run(cmd, cwd=WORK_DIR, check=True)\n \n # (Rest of the code is the same)\n ...\n\n```\n\n## Parameter Tuning Tips\n\n### Recommended Settings by Scene Type\n\n#### 1. Bounded Scenes (e.g., DTU Dataset)\n\n```python\ntrain_gaussian_splatting(\n data_dir=data_dir,\n iterations=2000,\n lambda_normal=0.05,\n lambda_distortion=0,\n depth_ratio=1 # Median depth\n)\n\n```\n\n#### 2. Unbounded/Large-Scale Scenes (e.g., MipNeRF360)\n\n```python\ntrain_gaussian_splatting(\n data_dir=data_dir,\n iterations=7000,\n lambda_normal=0.05,\n lambda_distortion=0,\n depth_ratio=0 # Mean depth (reduces artifacts)\n)\n\n```\n\n## Additional Optimizations\n\n### 1. Reducing Memory Usage\n\nWhile 2DGS is more efficient than 3DGS, consider the following for large-scale scenes:\n\n```python\n# Adjust the number of iterations\niterations=5000 # Reduced from 7000\n\n# Adjust image resolution\nsquare_size=512 # Reduced from 1024\n\n```\n\n### 2. High-Quality Mesh Extraction\n\n```python\n# Unbounded mesh extraction (Recommended)\nrender_video_and_mesh(\n model_path,\n output_video_path,\n extract_mesh=True,\n unbounded=True,\n mesh_res=1024 # High-resolution mesh\n)\n\n```\n\n## Troubleshooting\n\n### Issue 1: Training Does Not Converge\n\n* Occurs when the camera principal point is not at the image center.\n* Solved by converting the COLMAP camera model to PINHOLE (already implemented in the code).\n\n### Issue 2: Mesh is Not Generated / Broken\n\n* Bounded mode: Adjust the `depth_trunc` parameter.\n* Unbounded mode: No parameter adjustment required (Recommended).\n\n### Issue 3: Display Problems in 3DGS Viewer\n\n* 2DGS is not fully supported by the standard 3DGS viewer.\n* Recommended to use [SIBR Viewer](https://github.com/RongLiu-Leo/Gaussian-Splatting-Monitor).\n* Alternatively, use [Web Viewer](https://github.com/mkkellogg/GaussianSplats3D).\n\n## Performance Comparison\n\n| Feature | 3DGS | 2DGS |\n| --- | --- | --- |\n| Rendering Quality | High | High |\n| Mesh Quality | Low-Medium | High |\n| Training Speed | Fast | Slightly Faster (30-40% faster) |\n| Memory Usage | Medium | Medium |\n| Normal Precision | Low | High |\n\n## Reference Links\n\n* [2DGS Official Repository](https://github.com/hbb1/2d-gaussian-splatting)\n* [2DGS Paper](https://arxiv.org/pdf/2403.17888)\n* [Project Page](https://surfsplatting.github.io/)\n* [Colab Notebook](https://github.com/atakan-topaloglu/2d_gaussian_splatting_colab)\n* [Detailed Tutorial](https://learnopencv.com/2d-gaussian-splatting/)\n\n---\n","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}}]}
|
biplet_colmap_2dgs_colab_01.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|