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539",
|
| 12 |
+
"status": "completed"
|
| 13 |
+
},
|
| 14 |
+
"tags": [],
|
| 15 |
+
"id": "fb1f1fdc"
|
| 16 |
+
},
|
| 17 |
+
"source": [
|
| 18 |
+
"# **biplet-dino-colmap-2dgs**"
|
| 19 |
+
]
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"cell_type": "code",
|
| 23 |
+
"source": [
|
| 24 |
+
"#ใตใคใบใฎ็ฐใชใ็ปๅใๆฑใ\n",
|
| 25 |
+
"from google.colab import drive\n",
|
| 26 |
+
"drive.mount('/content/drive')"
|
| 27 |
+
],
|
| 28 |
+
"metadata": {
|
| 29 |
+
"colab": {
|
| 30 |
+
"base_uri": "https://localhost:8080/"
|
| 31 |
+
},
|
| 32 |
+
"id": "JON4rYSEOzCg",
|
| 33 |
+
"outputId": "26f4a0c4-30e0-46e2-f9f9-c3365732d1ac"
|
| 34 |
+
},
|
| 35 |
+
"id": "JON4rYSEOzCg",
|
| 36 |
+
"execution_count": 15,
|
| 37 |
+
"outputs": [
|
| 38 |
+
{
|
| 39 |
+
"output_type": "stream",
|
| 40 |
+
"name": "stdout",
|
| 41 |
+
"text": [
|
| 42 |
+
"Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
|
| 43 |
+
]
|
| 44 |
+
}
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"cell_type": "code",
|
| 49 |
+
"execution_count": 16,
|
| 50 |
+
"id": "22353010",
|
| 51 |
+
"metadata": {
|
| 52 |
+
"execution": {
|
| 53 |
+
"iopub.execute_input": "2026-01-10T18:17:32.181455Z",
|
| 54 |
+
"iopub.status.busy": "2026-01-10T18:17:32.180969Z",
|
| 55 |
+
"iopub.status.idle": "2026-01-10T18:17:32.355942Z",
|
| 56 |
+
"shell.execute_reply": "2026-01-10T18:17:32.355229Z"
|
| 57 |
+
},
|
| 58 |
+
"papermill": {
|
| 59 |
+
"duration": 0.179454,
|
| 60 |
+
"end_time": "2026-01-10T18:17:32.357275",
|
| 61 |
+
"exception": false,
|
| 62 |
+
"start_time": "2026-01-10T18:17:32.177821",
|
| 63 |
+
"status": "completed"
|
| 64 |
+
},
|
| 65 |
+
"tags": [],
|
| 66 |
+
"id": "22353010"
|
| 67 |
+
},
|
| 68 |
+
"outputs": [],
|
| 69 |
+
"source": [
|
| 70 |
+
"import os\n",
|
| 71 |
+
"import sys\n",
|
| 72 |
+
"import subprocess\n",
|
| 73 |
+
"import shutil\n",
|
| 74 |
+
"from pathlib import Path\n",
|
| 75 |
+
"import cv2\n",
|
| 76 |
+
"from PIL import Image\n",
|
| 77 |
+
"import glob\n",
|
| 78 |
+
"\n",
|
| 79 |
+
"IMAGE_PATH=\"/content/drive/MyDrive/your_folder/fountain100\"\n",
|
| 80 |
+
"\n",
|
| 81 |
+
"#WORK_DIR = '/content/gaussian-splatting'\n",
|
| 82 |
+
"WORK_DIR = \"/content/2d-gaussian-splatting\"\n",
|
| 83 |
+
"\n",
|
| 84 |
+
"OUTPUT_DIR = '/content/output'\n",
|
| 85 |
+
"COLMAP_DIR = '/content/colmap_data'"
|
| 86 |
+
]
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"cell_type": "code",
|
| 90 |
+
"execution_count": 17,
|
| 91 |
+
"id": "be6df249",
|
| 92 |
+
"metadata": {
|
| 93 |
+
"execution": {
|
| 94 |
+
"iopub.execute_input": "2026-01-10T18:17:32.363444Z",
|
| 95 |
+
"iopub.status.busy": "2026-01-10T18:17:32.363175Z",
|
| 96 |
+
"iopub.status.idle": "2026-01-10T18:22:43.720241Z",
|
| 97 |
+
"shell.execute_reply": "2026-01-10T18:22:43.719380Z"
|
| 98 |
+
},
|
| 99 |
+
"papermill": {
|
| 100 |
+
"duration": 311.361656,
|
| 101 |
+
"end_time": "2026-01-10T18:22:43.721610",
|
| 102 |
+
"exception": false,
|
| 103 |
+
"start_time": "2026-01-10T18:17:32.359954",
|
| 104 |
+
"status": "completed"
|
| 105 |
+
},
|
| 106 |
+
"tags": [],
|
| 107 |
+
"id": "be6df249",
|
| 108 |
+
"outputId": "49ae4583-0a1e-4957-eba1-7e6ca8279e36",
|
| 109 |
+
"colab": {
|
| 110 |
+
"base_uri": "https://localhost:8080/"
|
| 111 |
+
}
|
| 112 |
+
},
|
| 113 |
+
"outputs": [
|
| 114 |
+
{
|
| 115 |
+
"output_type": "stream",
|
| 116 |
+
"name": "stdout",
|
| 117 |
+
"text": [
|
| 118 |
+
"๐ Setting up COLAB environment (v8 - Python 3.12 compatible)\n",
|
| 119 |
+
"\n",
|
| 120 |
+
"======================================================================\n",
|
| 121 |
+
"STEP 0: Fix NumPy (Python 3.12 compatible)\n",
|
| 122 |
+
"======================================================================\n",
|
| 123 |
+
"Running: /usr/bin/python3 -m pip uninstall -y numpy\n",
|
| 124 |
+
"Running: /usr/bin/python3 -m pip install numpy==1.26.4\n",
|
| 125 |
+
"Running: /usr/bin/python3 -c import numpy; print('NumPy:', numpy.__version__)\n",
|
| 126 |
+
"\n",
|
| 127 |
+
"======================================================================\n",
|
| 128 |
+
"STEP 1: System packages\n",
|
| 129 |
+
"======================================================================\n",
|
| 130 |
+
"Running: apt-get update -qq\n",
|
| 131 |
+
"Running: apt-get install -y -qq colmap build-essential cmake git libopenblas-dev xvfb\n",
|
| 132 |
+
"\n",
|
| 133 |
+
"======================================================================\n",
|
| 134 |
+
"STEP 2: Clone Gaussian Splatting\n",
|
| 135 |
+
"======================================================================\n",
|
| 136 |
+
"โ Repository already exists\n",
|
| 137 |
+
"\n",
|
| 138 |
+
"======================================================================\n",
|
| 139 |
+
"STEP 3: Python packages (VERBOSE MODE)\n",
|
| 140 |
+
"======================================================================\n",
|
| 141 |
+
"\n",
|
| 142 |
+
"๐ฆ Installing PyTorch...\n",
|
| 143 |
+
"Running: /usr/bin/python3 -m pip install torch torchvision torchaudio\n",
|
| 144 |
+
"\n",
|
| 145 |
+
"๐ฆ Installing core utilities...\n",
|
| 146 |
+
"Running: /usr/bin/python3 -m pip install opencv-python pillow imageio imageio-ffmpeg plyfile tqdm tensorboard\n",
|
| 147 |
+
"\n",
|
| 148 |
+
"๐ฆ Installing transformers (NumPy 1.26 compatible)...\n",
|
| 149 |
+
"Running: /usr/bin/python3 -m pip install transformers==4.40.0\n",
|
| 150 |
+
"\n",
|
| 151 |
+
"๐ฆ Installing LightGlue stack...\n",
|
| 152 |
+
"Running: /usr/bin/python3 -m pip install kornia\n",
|
| 153 |
+
"Running: /usr/bin/python3 -m pip install h5py\n",
|
| 154 |
+
"Running: /usr/bin/python3 -m pip install matplotlib\n",
|
| 155 |
+
"Running: /usr/bin/python3 -m pip install pycolmap\n",
|
| 156 |
+
"\n",
|
| 157 |
+
"======================================================================\n",
|
| 158 |
+
"STEP 4: Detailed Verification\n",
|
| 159 |
+
"======================================================================\n",
|
| 160 |
+
"\n",
|
| 161 |
+
"๐ Testing NumPy...\n",
|
| 162 |
+
" โ NumPy: 2.0.2\n",
|
| 163 |
+
"\n",
|
| 164 |
+
"๐ Testing PyTorch...\n",
|
| 165 |
+
" โ PyTorch: 2.9.0+cu128\n",
|
| 166 |
+
" โ CUDA available: True\n",
|
| 167 |
+
" โ CUDA version: 12.8\n",
|
| 168 |
+
"\n",
|
| 169 |
+
"๐ Testing transformers...\n",
|
| 170 |
+
" โ transformers version: 4.40.0\n",
|
| 171 |
+
" โ AutoModel import: OK\n",
|
| 172 |
+
"\n",
|
| 173 |
+
"๐ Testing pycolmap...\n",
|
| 174 |
+
" โ pycolmap: OK\n",
|
| 175 |
+
"\n",
|
| 176 |
+
"๐ Testing kornia...\n",
|
| 177 |
+
" โ kornia: 0.8.2\n"
|
| 178 |
+
]
|
| 179 |
+
}
|
| 180 |
+
],
|
| 181 |
+
"source": [
|
| 182 |
+
"def run_cmd(cmd, check=True, capture=False, cwd=None): # โ cwd=None ใ่ฟฝๅ \n",
|
| 183 |
+
" \"\"\"Run command with better error handling\"\"\"\n",
|
| 184 |
+
" print(f\"Running: {' '.join(cmd)}\")\n",
|
| 185 |
+
" result = subprocess.run(\n",
|
| 186 |
+
" cmd,\n",
|
| 187 |
+
" capture_output=capture,\n",
|
| 188 |
+
" text=True,\n",
|
| 189 |
+
" check=False,\n",
|
| 190 |
+
" cwd=cwd # โ ใใใซๆธกใ\n",
|
| 191 |
+
" )\n",
|
| 192 |
+
" if check and result.returncode != 0:\n",
|
| 193 |
+
" print(f\"โ Command failed with code {result.returncode}\")\n",
|
| 194 |
+
" if capture:\n",
|
| 195 |
+
" print(f\"STDOUT: {result.stdout}\")\n",
|
| 196 |
+
" print(f\"STDERR: {result.stderr}\")\n",
|
| 197 |
+
" return result\n",
|
| 198 |
+
"\n",
|
| 199 |
+
"\n",
|
| 200 |
+
"def setup_environment():\n",
|
| 201 |
+
" \"\"\"\n",
|
| 202 |
+
" Colab environment setup for Gaussian Splatting + LightGlue + pycolmap\n",
|
| 203 |
+
" Python 3.12 compatible version (v8)\n",
|
| 204 |
+
" \"\"\"\n",
|
| 205 |
+
"\n",
|
| 206 |
+
" print(\"๐ Setting up COLAB environment (v8 - Python 3.12 compatible)\")\n",
|
| 207 |
+
"\n",
|
| 208 |
+
" WORK_DIR = \"2d-gaussian-splatting\"\n",
|
| 209 |
+
"\n",
|
| 210 |
+
" # =====================================================================\n",
|
| 211 |
+
" # STEP 0: NumPy FIX (Python 3.12 compatible)\n",
|
| 212 |
+
" # =====================================================================\n",
|
| 213 |
+
" print(\"\\n\" + \"=\"*70)\n",
|
| 214 |
+
" print(\"STEP 0: Fix NumPy (Python 3.12 compatible)\")\n",
|
| 215 |
+
" print(\"=\"*70)\n",
|
| 216 |
+
"\n",
|
| 217 |
+
" # Python 3.12 requires numpy >= 1.26\n",
|
| 218 |
+
" run_cmd([sys.executable, \"-m\", \"pip\", \"uninstall\", \"-y\", \"numpy\"])\n",
|
| 219 |
+
" run_cmd([sys.executable, \"-m\", \"pip\", \"install\", \"numpy==1.26.4\"])\n",
|
| 220 |
+
"\n",
|
| 221 |
+
" # sanity check\n",
|
| 222 |
+
" run_cmd([sys.executable, \"-c\", \"import numpy; print('NumPy:', numpy.__version__)\"])\n",
|
| 223 |
+
"\n",
|
| 224 |
+
" # =====================================================================\n",
|
| 225 |
+
" # STEP 1: System packages (Colab)\n",
|
| 226 |
+
" # =====================================================================\n",
|
| 227 |
+
" print(\"\\n\" + \"=\"*70)\n",
|
| 228 |
+
" print(\"STEP 1: System packages\")\n",
|
| 229 |
+
" print(\"=\"*70)\n",
|
| 230 |
+
"\n",
|
| 231 |
+
" run_cmd([\"apt-get\", \"update\", \"-qq\"])\n",
|
| 232 |
+
" run_cmd([\n",
|
| 233 |
+
" \"apt-get\", \"install\", \"-y\", \"-qq\",\n",
|
| 234 |
+
" \"colmap\",\n",
|
| 235 |
+
" \"build-essential\",\n",
|
| 236 |
+
" \"cmake\",\n",
|
| 237 |
+
" \"git\",\n",
|
| 238 |
+
" \"libopenblas-dev\",\n",
|
| 239 |
+
" \"xvfb\"\n",
|
| 240 |
+
" ])\n",
|
| 241 |
+
"\n",
|
| 242 |
+
" # virtual display (COLMAP / OpenCV safety)\n",
|
| 243 |
+
" os.environ[\"QT_QPA_PLATFORM\"] = \"offscreen\"\n",
|
| 244 |
+
" os.environ[\"DISPLAY\"] = \":99\"\n",
|
| 245 |
+
" subprocess.Popen(\n",
|
| 246 |
+
" [\"Xvfb\", \":99\", \"-screen\", \"0\", \"1024x768x24\"],\n",
|
| 247 |
+
" stdout=subprocess.DEVNULL,\n",
|
| 248 |
+
" stderr=subprocess.DEVNULL\n",
|
| 249 |
+
" )\n",
|
| 250 |
+
"\n",
|
| 251 |
+
" # =====================================================================\n",
|
| 252 |
+
" # STEP 2: Clone 2D Gaussian Splatting\n",
|
| 253 |
+
" # =====================================================================\n",
|
| 254 |
+
" print(\"\\n\" + \"=\"*70)\n",
|
| 255 |
+
" print(\"STEP 2: Clone Gaussian Splatting\")\n",
|
| 256 |
+
" print(\"=\"*70)\n",
|
| 257 |
+
"\n",
|
| 258 |
+
" if not os.path.exists(WORK_DIR):\n",
|
| 259 |
+
" run_cmd([\n",
|
| 260 |
+
" \"git\", \"clone\", \"--recursive\",\n",
|
| 261 |
+
" \"https://github.com/hbb1/2d-gaussian-splatting.git\",\n",
|
| 262 |
+
" WORK_DIR\n",
|
| 263 |
+
" ])\n",
|
| 264 |
+
" else:\n",
|
| 265 |
+
" print(\"โ Repository already exists\")\n",
|
| 266 |
+
"\n",
|
| 267 |
+
" # =====================================================================\n",
|
| 268 |
+
" # STEP 3: Python packages (FIXED ORDER & VERSIONS)\n",
|
| 269 |
+
" # =====================================================================\n",
|
| 270 |
+
" print(\"\\n\" + \"=\"*70)\n",
|
| 271 |
+
" print(\"STEP 3: Python packages (VERBOSE MODE)\")\n",
|
| 272 |
+
" print(\"=\"*70)\n",
|
| 273 |
+
"\n",
|
| 274 |
+
" # ---- PyTorch (Colab CUDAๅฏพๅฟ) ----\n",
|
| 275 |
+
" print(\"\\n๐ฆ Installing PyTorch...\")\n",
|
| 276 |
+
" run_cmd([\n",
|
| 277 |
+
" sys.executable, \"-m\", \"pip\", \"install\",\n",
|
| 278 |
+
" \"torch\", \"torchvision\", \"torchaudio\"\n",
|
| 279 |
+
" ])\n",
|
| 280 |
+
"\n",
|
| 281 |
+
" # ---- Core utils ----\n",
|
| 282 |
+
" print(\"\\n๐ฆ Installing core utilities...\")\n",
|
| 283 |
+
" run_cmd([\n",
|
| 284 |
+
" sys.executable, \"-m\", \"pip\", \"install\",\n",
|
| 285 |
+
" \"opencv-python\",\n",
|
| 286 |
+
" \"pillow\",\n",
|
| 287 |
+
" \"imageio\",\n",
|
| 288 |
+
" \"imageio-ffmpeg\",\n",
|
| 289 |
+
" \"plyfile\",\n",
|
| 290 |
+
" \"tqdm\",\n",
|
| 291 |
+
" \"tensorboard\"\n",
|
| 292 |
+
" ])\n",
|
| 293 |
+
"\n",
|
| 294 |
+
" # ---- transformers (NumPy 1.26 compatible) ----\n",
|
| 295 |
+
" print(\"\\n๐ฆ Installing transformers (NumPy 1.26 compatible)...\")\n",
|
| 296 |
+
" # Install transformers with proper dependencies\n",
|
| 297 |
+
" run_cmd([\n",
|
| 298 |
+
" sys.executable, \"-m\", \"pip\", \"install\",\n",
|
| 299 |
+
" \"transformers==4.40.0\"\n",
|
| 300 |
+
" ])\n",
|
| 301 |
+
"\n",
|
| 302 |
+
" # ---- LightGlue stack (GITHUB INSTALL) ----\n",
|
| 303 |
+
" print(\"\\n๐ฆ Installing LightGlue stack...\")\n",
|
| 304 |
+
"\n",
|
| 305 |
+
" # Install kornia first\n",
|
| 306 |
+
" run_cmd([sys.executable, \"-m\", \"pip\", \"install\", \"kornia\"])\n",
|
| 307 |
+
"\n",
|
| 308 |
+
" # Install h5py (sometimes needed)\n",
|
| 309 |
+
" run_cmd([sys.executable, \"-m\", \"pip\", \"install\", \"h5py\"])\n",
|
| 310 |
+
"\n",
|
| 311 |
+
" # Install matplotlib (LightGlue dependency)\n",
|
| 312 |
+
" run_cmd([sys.executable, \"-m\", \"pip\", \"install\", \"matplotlib\"])\n",
|
| 313 |
+
"\n",
|
| 314 |
+
" # Install pycolmap\n",
|
| 315 |
+
" run_cmd([sys.executable, \"-m\", \"pip\", \"install\", \"pycolmap\"])\n",
|
| 316 |
+
"\n",
|
| 317 |
+
"\n",
|
| 318 |
+
"\n",
|
| 319 |
+
" # =====================================================================\n",
|
| 320 |
+
" # STEP 4: Detailed Verification\n",
|
| 321 |
+
" # =====================================================================\n",
|
| 322 |
+
" print(\"\\n\" + \"=\"*70)\n",
|
| 323 |
+
" print(\"STEP 4: Detailed Verification\")\n",
|
| 324 |
+
" print(\"=\"*70)\n",
|
| 325 |
+
"\n",
|
| 326 |
+
" # NumPy (verify version first)\n",
|
| 327 |
+
" print(\"\\n๐ Testing NumPy...\")\n",
|
| 328 |
+
" try:\n",
|
| 329 |
+
" import numpy as np\n",
|
| 330 |
+
" print(f\" โ NumPy: {np.__version__}\")\n",
|
| 331 |
+
" except Exception as e:\n",
|
| 332 |
+
" print(f\" โ NumPy failed: {e}\")\n",
|
| 333 |
+
"\n",
|
| 334 |
+
" # PyTorch\n",
|
| 335 |
+
" print(\"\\n๐ Testing PyTorch...\")\n",
|
| 336 |
+
" try:\n",
|
| 337 |
+
" import torch\n",
|
| 338 |
+
" print(f\" โ PyTorch: {torch.__version__}\")\n",
|
| 339 |
+
" print(f\" โ CUDA available: {torch.cuda.is_available()}\")\n",
|
| 340 |
+
" if torch.cuda.is_available():\n",
|
| 341 |
+
" print(f\" โ CUDA version: {torch.version.cuda}\")\n",
|
| 342 |
+
" except Exception as e:\n",
|
| 343 |
+
" print(f\" โ PyTorch failed: {e}\")\n",
|
| 344 |
+
"\n",
|
| 345 |
+
" # transformers\n",
|
| 346 |
+
" print(\"\\n๐ Testing transformers...\")\n",
|
| 347 |
+
" try:\n",
|
| 348 |
+
" import transformers\n",
|
| 349 |
+
" print(f\" โ transformers version: {transformers.__version__}\")\n",
|
| 350 |
+
" from transformers import AutoModel\n",
|
| 351 |
+
" print(f\" โ AutoModel import: OK\")\n",
|
| 352 |
+
" except Exception as e:\n",
|
| 353 |
+
" print(f\" โ transformers failed: {e}\")\n",
|
| 354 |
+
" print(f\" Attempting detailed diagnosis...\")\n",
|
| 355 |
+
" result = run_cmd([\n",
|
| 356 |
+
" sys.executable, \"-c\",\n",
|
| 357 |
+
" \"import transformers; print(transformers.__version__)\"\n",
|
| 358 |
+
" ], capture=True)\n",
|
| 359 |
+
" print(f\" Output: {result.stdout}\")\n",
|
| 360 |
+
" print(f\" Error: {result.stderr}\")\n",
|
| 361 |
+
"\n",
|
| 362 |
+
" # pycolmap\n",
|
| 363 |
+
" print(\"\\n๐ Testing pycolmap...\")\n",
|
| 364 |
+
" try:\n",
|
| 365 |
+
" import pycolmap\n",
|
| 366 |
+
" print(f\" โ pycolmap: OK\")\n",
|
| 367 |
+
" except Exception as e:\n",
|
| 368 |
+
" print(f\" โ pycolmap failed: {e}\")\n",
|
| 369 |
+
"\n",
|
| 370 |
+
" # kornia\n",
|
| 371 |
+
" print(\"\\n๐ Testing kornia...\")\n",
|
| 372 |
+
" try:\n",
|
| 373 |
+
" import kornia\n",
|
| 374 |
+
" print(f\" โ kornia: {kornia.__version__}\")\n",
|
| 375 |
+
" except Exception as e:\n",
|
| 376 |
+
" print(f\" โ kornia failed: {e}\")\n",
|
| 377 |
+
"\n",
|
| 378 |
+
" return WORK_DIR\n",
|
| 379 |
+
"\n",
|
| 380 |
+
"\n",
|
| 381 |
+
"if __name__ == \"__main__\":\n",
|
| 382 |
+
" setup_environment()"
|
| 383 |
+
]
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"cell_type": "code",
|
| 387 |
+
"source": [],
|
| 388 |
+
"metadata": {
|
| 389 |
+
"id": "3UEcAPBILz6Z"
|
| 390 |
+
},
|
| 391 |
+
"id": "3UEcAPBILz6Z",
|
| 392 |
+
"execution_count": 17,
|
| 393 |
+
"outputs": []
|
| 394 |
+
},
|
| 395 |
+
{
|
| 396 |
+
"cell_type": "code",
|
| 397 |
+
"source": [
|
| 398 |
+
"# =====================================================================\n",
|
| 399 |
+
"# STEP 4: Build 2D GS submodules (็ขบๅฎใชๆนๆณ)\n",
|
| 400 |
+
"# =====================================================================\n",
|
| 401 |
+
"print(\"\\n\" + \"=\"*70)\n",
|
| 402 |
+
"print(\"STEP 5: Build Gaussian Splatting submodules\")\n",
|
| 403 |
+
"print(\"=\"*70)\n",
|
| 404 |
+
"\n",
|
| 405 |
+
"# diff-surfel-rasterization\n",
|
| 406 |
+
"\n",
|
| 407 |
+
"path = os.path.join(WORK_DIR, \"submodules\", \"diff-surfel-rasterization\")\n",
|
| 408 |
+
"url = \"https://github.com/hbb1/diff-surfel-rasterization.git\"\n",
|
| 409 |
+
"name = os.path.basename(path)\n",
|
| 410 |
+
"print(f\"\\n๐ฆ Processing {name}...\")\n",
|
| 411 |
+
"if not os.path.exists(path):\n",
|
| 412 |
+
" print(f\" > Cloning {url}...\")\n",
|
| 413 |
+
" # ่ฆชใใฃใฌใฏใใชใๅญๅจใใใใจใ็ขบ่ช\n",
|
| 414 |
+
" os.makedirs(os.path.dirname(path), exist_ok=True)\n",
|
| 415 |
+
" run_cmd([\"git\", \"clone\", url, path])\n",
|
| 416 |
+
"else:\n",
|
| 417 |
+
" print(f\" โ {name} already exists.\")\n",
|
| 418 |
+
"# 2. setup.py install (ใณใณใใคใซ)\n",
|
| 419 |
+
"print(f\" > Compiling and Installing {name}...\")\n",
|
| 420 |
+
"result = run_cmd(\n",
|
| 421 |
+
" [sys.executable, \"setup.py\", \"install\"],\n",
|
| 422 |
+
" cwd=path,\n",
|
| 423 |
+
" check=False, # ใจใฉใผใงใๆญขใใชใ\n",
|
| 424 |
+
" capture=True\n",
|
| 425 |
+
")\n",
|
| 426 |
+
"if result.returncode != 0:\n",
|
| 427 |
+
" print(f\"โ Failed to build {name}\")\n",
|
| 428 |
+
" print(\"--- STDERR ---\")\n",
|
| 429 |
+
" print(result.stderr)\n",
|
| 430 |
+
"else:\n",
|
| 431 |
+
" print(f\"โ
Successfully built {name}\")"
|
| 432 |
+
],
|
| 433 |
+
"metadata": {
|
| 434 |
+
"colab": {
|
| 435 |
+
"base_uri": "https://localhost:8080/"
|
| 436 |
+
},
|
| 437 |
+
"id": "kLdJ-FeT-kQc",
|
| 438 |
+
"outputId": "fa637887-c7a9-45c0-fc4d-738456d119d9"
|
| 439 |
+
},
|
| 440 |
+
"id": "kLdJ-FeT-kQc",
|
| 441 |
+
"execution_count": 18,
|
| 442 |
+
"outputs": [
|
| 443 |
+
{
|
| 444 |
+
"output_type": "stream",
|
| 445 |
+
"name": "stdout",
|
| 446 |
+
"text": [
|
| 447 |
+
"\n",
|
| 448 |
+
"======================================================================\n",
|
| 449 |
+
"STEP 5: Build Gaussian Splatting submodules\n",
|
| 450 |
+
"======================================================================\n",
|
| 451 |
+
"\n",
|
| 452 |
+
"๐ฆ Processing diff-surfel-rasterization...\n",
|
| 453 |
+
" โ diff-surfel-rasterization already exists.\n",
|
| 454 |
+
" > Compiling and Installing diff-surfel-rasterization...\n",
|
| 455 |
+
"Running: /usr/bin/python3 setup.py install\n",
|
| 456 |
+
"โ
Successfully built diff-surfel-rasterization\n"
|
| 457 |
+
]
|
| 458 |
+
}
|
| 459 |
+
]
|
| 460 |
+
},
|
| 461 |
+
{
|
| 462 |
+
"cell_type": "code",
|
| 463 |
+
"source": [
|
| 464 |
+
"import os\n",
|
| 465 |
+
"import sys\n",
|
| 466 |
+
"import shutil\n",
|
| 467 |
+
"import subprocess\n",
|
| 468 |
+
"\n",
|
| 469 |
+
"# --- ๅๆบๅ: ็ฐๅขใฎๆดๅ ---\n",
|
| 470 |
+
"print(\"Configuring build environment...\")\n",
|
| 471 |
+
"# 1. CUDAใณใณใใคใฉใฎ็ขบ่ช\n",
|
| 472 |
+
"!nvcc --version\n",
|
| 473 |
+
"\n",
|
| 474 |
+
"# 2. ๅฟ
้ ใใผใซใฎใคใณในใใผใซ (ninjaใฏใใซใใๅฎๅฎใป้ซ้ๅใใใพใ)\n",
|
| 475 |
+
"!pip install setuptools wheel ninja\n",
|
| 476 |
+
"\n",
|
| 477 |
+
"# 3. ็ฐๅขๅคๆฐใฎใปใใใขใใ (CUDAใฎใในใๆ็คบ็ใซๆๅฎ)\n",
|
| 478 |
+
"os.environ[\"CUDA_HOME\"] = \"/usr/local/cuda\"\n",
|
| 479 |
+
"os.environ[\"PATH\"] = f'{os.environ[\"CUDA_HOME\"]}/bin:{os.environ[\"PATH\"]}'\n",
|
| 480 |
+
"os.environ[\"LD_LIBRARY_PATH\"] = f'{os.environ[\"CUDA_HOME\"]}/lib64:{os.environ[\"LD_LIBRARY_PATH\"]}'\n",
|
| 481 |
+
"# ใกใขใชไธ่ถณใซใใใฏใฉใใทใฅใ้ฒใใใใไธฆๅใใซใๆฐใๅถ้\n",
|
| 482 |
+
"os.environ[\"MAX_JOBS\"] = \"2\"\n",
|
| 483 |
+
"\n",
|
| 484 |
+
"def run_cmd(cmd, cwd=None, check=True):\n",
|
| 485 |
+
" \"\"\"ใณใใณใๅฎ่ก็จใฎใใซใใผ้ขๆฐ\"\"\"\n",
|
| 486 |
+
" return subprocess.run(cmd, cwd=cwd, capture_output=True, text=True, check=check)\n",
|
| 487 |
+
"\n",
|
| 488 |
+
"def install_submodule(name, url, base_dir):\n",
|
| 489 |
+
" \"\"\"ๅๅฅใฎใตใใขใธใฅใผใซใใคใณในใใผใซ\"\"\"\n",
|
| 490 |
+
" print(f\"\\n{'='*70}\")\n",
|
| 491 |
+
" print(f\"Installing {name}\")\n",
|
| 492 |
+
" print(f\"{'='*70}\")\n",
|
| 493 |
+
"\n",
|
| 494 |
+
" # ็ตถๅฏพใในใไฝฟ็จ\n",
|
| 495 |
+
" path = os.path.abspath(os.path.join(base_dir, \"submodules\", name))\n",
|
| 496 |
+
" print(f\" > Target path: {path}\")\n",
|
| 497 |
+
"\n",
|
| 498 |
+
" # Step 1: ๆขๅญใๅ้ค\n",
|
| 499 |
+
" if os.path.exists(path):\n",
|
| 500 |
+
" print(f\" > Removing old {name}...\")\n",
|
| 501 |
+
" shutil.rmtree(path)\n",
|
| 502 |
+
"\n",
|
| 503 |
+
" # Step 2: ใฏใญใผใณ\n",
|
| 504 |
+
" print(f\" > Cloning from {url}...\")\n",
|
| 505 |
+
" os.makedirs(os.path.dirname(path), exist_ok=True)\n",
|
| 506 |
+
" try:\n",
|
| 507 |
+
" run_cmd([\"git\", \"clone\", url, path])\n",
|
| 508 |
+
" except subprocess.CalledProcessError as e:\n",
|
| 509 |
+
" print(f\"โ Failed to clone {name}\")\n",
|
| 510 |
+
" print(e.stderr)\n",
|
| 511 |
+
" return False\n",
|
| 512 |
+
"\n",
|
| 513 |
+
" # Step 3: ใใกใคใซ็ขบ่ช (spatial.cu ็ญใฎๅญๅจใใใงใใฏ)\n",
|
| 514 |
+
" print(f\" > Checking cloned files...\")\n",
|
| 515 |
+
" files = os.listdir(path)\n",
|
| 516 |
+
" print(f\" > Files in {name}: {files[:10]}...\")\n",
|
| 517 |
+
"\n",
|
| 518 |
+
" # Step 4: ็นๅฎใขใธใฅใผใซใฎใตใใขใธใฅใผใซๅๆๅ\n",
|
| 519 |
+
" if name == \"diff-surfel-rasterization\":\n",
|
| 520 |
+
" print(f\" > Initializing GLM submodule...\")\n",
|
| 521 |
+
" run_cmd([\"git\", \"submodule\", \"update\", \"--init\", \"--recursive\"], cwd=path)\n",
|
| 522 |
+
"\n",
|
| 523 |
+
" # Step 5: ใใซใใญใฃใใทใฅๅ้ค\n",
|
| 524 |
+
" build_dir = os.path.join(path, \"build\")\n",
|
| 525 |
+
" if os.path.exists(build_dir):\n",
|
| 526 |
+
" print(f\" > Cleaning build cache...\")\n",
|
| 527 |
+
" shutil.rmtree(build_dir)\n",
|
| 528 |
+
"\n",
|
| 529 |
+
" # Step 6: ใคใณในใใผใซ\n",
|
| 530 |
+
" print(f\" > Installing {name} (This may take a few minutes)...\")\n",
|
| 531 |
+
" # ็ฐๅขๅคๆฐใๆ็คบ็ใซๅผใ็ถใ\n",
|
| 532 |
+
" current_env = os.environ.copy()\n",
|
| 533 |
+
"\n",
|
| 534 |
+
" result = subprocess.run(\n",
|
| 535 |
+
" [sys.executable, \"-m\", \"pip\", \"install\", \"-e\", \".\", \"--no-build-isolation\", \"-v\"],\n",
|
| 536 |
+
" cwd=path,\n",
|
| 537 |
+
" env=current_env,\n",
|
| 538 |
+
" capture_output=True,\n",
|
| 539 |
+
" text=True\n",
|
| 540 |
+
" )\n",
|
| 541 |
+
"\n",
|
| 542 |
+
" if result.returncode != 0:\n",
|
| 543 |
+
" print(f\"โ Failed to install {name}\")\n",
|
| 544 |
+
" # C++/CUDAใฎใใซใใจใฉใผใฏ stdout ใซๅบใใใจใๅคใใใใไธกๆนๅบๅ\n",
|
| 545 |
+
" print(\"\\n--- STDOUT (Build Logs) ---\")\n",
|
| 546 |
+
" stdout_lines = result.stdout.split('\\n')\n",
|
| 547 |
+
" print('\\n'.join(stdout_lines[-60:])) # ๆๅพใฎ60่กใ่กจ็คบ\n",
|
| 548 |
+
"\n",
|
| 549 |
+
" print(\"\\n--- STDERR (Error Details) ---\")\n",
|
| 550 |
+
" print(result.stderr)\n",
|
| 551 |
+
" return False\n",
|
| 552 |
+
"\n",
|
| 553 |
+
" print(f\"โ
Successfully installed {name}\")\n",
|
| 554 |
+
" return True\n",
|
| 555 |
+
"\n",
|
| 556 |
+
"# =====================================================================\n",
|
| 557 |
+
"# STEP 4: Build 2D GS submodules\n",
|
| 558 |
+
"# =====================================================================\n",
|
| 559 |
+
"print(\"\\n\" + \"=\"*70)\n",
|
| 560 |
+
"print(\"STEP 4: Build Gaussian Splatting submodules\")\n",
|
| 561 |
+
"print(\"=\"*70)\n",
|
| 562 |
+
"\n",
|
| 563 |
+
"# Colabใฎๅ ดๅใฏ็ตถๅฏพใใน\n",
|
| 564 |
+
"WORK_DIR = \"/content/2d-gaussian-splatting\"\n",
|
| 565 |
+
"\n",
|
| 566 |
+
"# ๅใตใใขใธใฅใผใซใฎใคใณในใใผใซ\n",
|
| 567 |
+
"# simple-knn\n",
|
| 568 |
+
"success_knn = install_submodule(\n",
|
| 569 |
+
" \"simple-knn\",\n",
|
| 570 |
+
" \"https://github.com/tztechno/simple-knn.git\",\n",
|
| 571 |
+
" WORK_DIR\n",
|
| 572 |
+
")\n",
|
| 573 |
+
"\n",
|
| 574 |
+
"\n",
|
| 575 |
+
"# ็ตๆ่กจ็คบ\n",
|
| 576 |
+
"print(\"\\n\" + \"=\"*70)\n",
|
| 577 |
+
"print(\"Installation Summary\")\n",
|
| 578 |
+
"print(\"=\"*70)\n",
|
| 579 |
+
"print(f\"simple-knn: {'โ
Success' if success_knn else 'โ Failed'}\")"
|
| 580 |
+
],
|
| 581 |
+
"metadata": {
|
| 582 |
+
"colab": {
|
| 583 |
+
"base_uri": "https://localhost:8080/"
|
| 584 |
+
},
|
| 585 |
+
"id": "qYgJl2Fw_Phk",
|
| 586 |
+
"outputId": "d0d52b5e-1c2a-44f9-abba-66047f67fb60"
|
| 587 |
+
},
|
| 588 |
+
"id": "qYgJl2Fw_Phk",
|
| 589 |
+
"execution_count": 19,
|
| 590 |
+
"outputs": [
|
| 591 |
+
{
|
| 592 |
+
"output_type": "stream",
|
| 593 |
+
"name": "stdout",
|
| 594 |
+
"text": [
|
| 595 |
+
"Configuring build environment...\n",
|
| 596 |
+
"nvcc: NVIDIA (R) Cuda compiler driver\n",
|
| 597 |
+
"Copyright (c) 2005-2025 NVIDIA Corporation\n",
|
| 598 |
+
"Built on Fri_Feb_21_20:23:50_PST_2025\n",
|
| 599 |
+
"Cuda compilation tools, release 12.8, V12.8.93\n",
|
| 600 |
+
"Build cuda_12.8.r12.8/compiler.35583870_0\n",
|
| 601 |
+
"\u001b[33mDEPRECATION: Loading egg at /usr/local/lib/python3.12/dist-packages/diff_surfel_rasterization-0.0.1-py3.12-linux-x86_64.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330\u001b[0m\u001b[33m\n",
|
| 602 |
+
"\u001b[0mRequirement already satisfied: setuptools in /usr/local/lib/python3.12/dist-packages (75.2.0)\n",
|
| 603 |
+
"Requirement already satisfied: wheel in /usr/local/lib/python3.12/dist-packages (0.46.3)\n",
|
| 604 |
+
"Requirement already satisfied: ninja in /usr/local/lib/python3.12/dist-packages (1.13.0)\n",
|
| 605 |
+
"Requirement already satisfied: packaging>=24.0 in /usr/local/lib/python3.12/dist-packages (from wheel) (26.0)\n",
|
| 606 |
+
"\n",
|
| 607 |
+
"======================================================================\n",
|
| 608 |
+
"STEP 4: Build Gaussian Splatting submodules\n",
|
| 609 |
+
"======================================================================\n",
|
| 610 |
+
"\n",
|
| 611 |
+
"======================================================================\n",
|
| 612 |
+
"Installing simple-knn\n",
|
| 613 |
+
"======================================================================\n",
|
| 614 |
+
" > Target path: /content/2d-gaussian-splatting/submodules/simple-knn\n",
|
| 615 |
+
" > Removing old simple-knn...\n",
|
| 616 |
+
" > Cloning from https://github.com/tztechno/simple-knn.git...\n",
|
| 617 |
+
" > Checking cloned files...\n",
|
| 618 |
+
" > Files in simple-knn: ['README.md', 'ext.cpp', 'spatial.h', '.gitignore', 'simple_knn', 'simple_knn0.cu', 'spatial.cu', 'setup.py', '.git', 'simple_knn.cu']...\n",
|
| 619 |
+
" > Installing simple-knn (This may take a few minutes)...\n",
|
| 620 |
+
"โ
Successfully installed simple-knn\n",
|
| 621 |
+
"\n",
|
| 622 |
+
"======================================================================\n",
|
| 623 |
+
"Installation Summary\n",
|
| 624 |
+
"======================================================================\n",
|
| 625 |
+
"simple-knn: โ
Success\n"
|
| 626 |
+
]
|
| 627 |
+
}
|
| 628 |
+
]
|
| 629 |
+
},
|
| 630 |
+
{
|
| 631 |
+
"cell_type": "code",
|
| 632 |
+
"source": [
|
| 633 |
+
"!pip install trimesh"
|
| 634 |
+
],
|
| 635 |
+
"metadata": {
|
| 636 |
+
"colab": {
|
| 637 |
+
"base_uri": "https://localhost:8080/"
|
| 638 |
+
},
|
| 639 |
+
"id": "-ZfMABILvydS",
|
| 640 |
+
"outputId": "17c09295-ca06-4677-b1c3-4faeae1a60fe"
|
| 641 |
+
},
|
| 642 |
+
"id": "-ZfMABILvydS",
|
| 643 |
+
"execution_count": 20,
|
| 644 |
+
"outputs": [
|
| 645 |
+
{
|
| 646 |
+
"output_type": "stream",
|
| 647 |
+
"name": "stdout",
|
| 648 |
+
"text": [
|
| 649 |
+
"\u001b[33mDEPRECATION: Loading egg at /usr/local/lib/python3.12/dist-packages/diff_surfel_rasterization-0.0.1-py3.12-linux-x86_64.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation. Discussion can be found at https://github.com/pypa/pip/issues/12330\u001b[0m\u001b[33m\n",
|
| 650 |
+
"\u001b[0mRequirement already satisfied: trimesh in /usr/local/lib/python3.12/dist-packages (4.11.2)\n",
|
| 651 |
+
"Requirement already satisfied: numpy>=1.20 in /usr/local/lib/python3.12/dist-packages (from trimesh) (2.4.2)\n"
|
| 652 |
+
]
|
| 653 |
+
}
|
| 654 |
+
]
|
| 655 |
+
},
|
| 656 |
+
{
|
| 657 |
+
"cell_type": "code",
|
| 658 |
+
"source": [
|
| 659 |
+
"def setup_2dgs_environment():\n",
|
| 660 |
+
" \"\"\"2DGS็ฐๅขใฎใปใใใขใใ๏ผๅฎๅ
จ็๏ผ\"\"\"\n",
|
| 661 |
+
" print(\"Setting up 2DGS environment...\")\n",
|
| 662 |
+
"\n",
|
| 663 |
+
" # ๅฟ
่ฆใชใใใฑใผใธใใในใฆใคใณในใใผใซ\n",
|
| 664 |
+
" packages = [\n",
|
| 665 |
+
" 'plyfile',\n",
|
| 666 |
+
" 'mediapy',\n",
|
| 667 |
+
" 'open3d', # โ ใใใ่ฟฝๅ \n",
|
| 668 |
+
" ]\n",
|
| 669 |
+
"\n",
|
| 670 |
+
" for pkg in packages:\n",
|
| 671 |
+
" print(f\"Installing {pkg}...\")\n",
|
| 672 |
+
" subprocess.run(['pip', 'install', pkg], check=True)\n",
|
| 673 |
+
"\n",
|
| 674 |
+
" # 2DGSใชใใธใใชใฎใฏใญใผใณ\n",
|
| 675 |
+
" if not os.path.exists(WORK_DIR):\n",
|
| 676 |
+
" subprocess.run([\n",
|
| 677 |
+
" 'git', 'clone', '--recursive',\n",
|
| 678 |
+
" 'https://github.com/hbb1/2d-gaussian-splatting.git',\n",
|
| 679 |
+
" WORK_DIR\n",
|
| 680 |
+
" ], check=True)\n",
|
| 681 |
+
"\n",
|
| 682 |
+
" subprocess.run(['git', 'submodule', 'update', '--init', '--recursive'],\n",
|
| 683 |
+
" cwd=WORK_DIR, check=True)\n",
|
| 684 |
+
"\n",
|
| 685 |
+
" build_2dgs_submodules()\n",
|
| 686 |
+
"\n",
|
| 687 |
+
" print(\"โ
2DGS environment setup complete\")"
|
| 688 |
+
],
|
| 689 |
+
"metadata": {
|
| 690 |
+
"id": "kXPLG7byqFlr"
|
| 691 |
+
},
|
| 692 |
+
"id": "kXPLG7byqFlr",
|
| 693 |
+
"execution_count": 21,
|
| 694 |
+
"outputs": []
|
| 695 |
+
},
|
| 696 |
+
{
|
| 697 |
+
"cell_type": "code",
|
| 698 |
+
"source": [],
|
| 699 |
+
"metadata": {
|
| 700 |
+
"id": "55dtC6ByqJRY"
|
| 701 |
+
},
|
| 702 |
+
"id": "55dtC6ByqJRY",
|
| 703 |
+
"execution_count": 21,
|
| 704 |
+
"outputs": []
|
| 705 |
+
},
|
| 706 |
+
{
|
| 707 |
+
"cell_type": "code",
|
| 708 |
+
"source": [
|
| 709 |
+
"\n",
|
| 710 |
+
"\n",
|
| 711 |
+
"\n",
|
| 712 |
+
"# ๅๅบฆใฌใณใใชใณใฐๅฎ่ก\n",
|
| 713 |
+
"import subprocess\n",
|
| 714 |
+
"result = subprocess.run(\n",
|
| 715 |
+
" ['/usr/bin/python3', 'render.py',\n",
|
| 716 |
+
" '-m', '/content/2d-gaussian-splatting/output/video',\n",
|
| 717 |
+
" '--iteration', '1000',\n",
|
| 718 |
+
" '--skip_test',\n",
|
| 719 |
+
" '--skip_train'],\n",
|
| 720 |
+
" cwd='/content/2d-gaussian-splatting',\n",
|
| 721 |
+
" capture_output=True,\n",
|
| 722 |
+
" text=True\n",
|
| 723 |
+
")\n",
|
| 724 |
+
"\n",
|
| 725 |
+
"print(\"=== STDOUT ===\")\n",
|
| 726 |
+
"print(result.stdout)\n",
|
| 727 |
+
"print(\"\\n=== STDERR ===\")\n",
|
| 728 |
+
"print(result.stderr)\n",
|
| 729 |
+
"print(f\"\\n=== EXIT CODE: {result.returncode} ===\")"
|
| 730 |
+
],
|
| 731 |
+
"metadata": {
|
| 732 |
+
"colab": {
|
| 733 |
+
"base_uri": "https://localhost:8080/"
|
| 734 |
+
},
|
| 735 |
+
"id": "vRxNgRnypv0l",
|
| 736 |
+
"outputId": "5499a948-f78c-4ab4-9683-a428a36ef48a"
|
| 737 |
+
},
|
| 738 |
+
"id": "vRxNgRnypv0l",
|
| 739 |
+
"execution_count": 22,
|
| 740 |
+
"outputs": [
|
| 741 |
+
{
|
| 742 |
+
"output_type": "stream",
|
| 743 |
+
"name": "stdout",
|
| 744 |
+
"text": [
|
| 745 |
+
"=== STDOUT ===\n",
|
| 746 |
+
"\n",
|
| 747 |
+
"\n",
|
| 748 |
+
"=== STDERR ===\n",
|
| 749 |
+
"Traceback (most recent call last):\n",
|
| 750 |
+
" File \"/content/2d-gaussian-splatting/render.py\", line 23, in <module>\n",
|
| 751 |
+
" from utils.mesh_utils import GaussianExtractor, to_cam_open3d, post_process_mesh\n",
|
| 752 |
+
" File \"/content/2d-gaussian-splatting/utils/mesh_utils.py\", line 17, in <module>\n",
|
| 753 |
+
" from utils.render_utils import save_img_f32, save_img_u8\n",
|
| 754 |
+
" File \"/content/2d-gaussian-splatting/utils/render_utils.py\", line 22, in <module>\n",
|
| 755 |
+
" import mediapy as media\n",
|
| 756 |
+
"ModuleNotFoundError: No module named 'mediapy'\n",
|
| 757 |
+
"\n",
|
| 758 |
+
"\n",
|
| 759 |
+
"=== EXIT CODE: 1 ===\n"
|
| 760 |
+
]
|
| 761 |
+
}
|
| 762 |
+
]
|
| 763 |
+
},
|
| 764 |
+
{
|
| 765 |
+
"cell_type": "code",
|
| 766 |
+
"source": [],
|
| 767 |
+
"metadata": {
|
| 768 |
+
"id": "1W62vlfhe9TS"
|
| 769 |
+
},
|
| 770 |
+
"id": "1W62vlfhe9TS",
|
| 771 |
+
"execution_count": 22,
|
| 772 |
+
"outputs": []
|
| 773 |
+
},
|
| 774 |
+
{
|
| 775 |
+
"cell_type": "code",
|
| 776 |
+
"source": [
|
| 777 |
+
"!nvcc --version\n",
|
| 778 |
+
"import torch\n",
|
| 779 |
+
"print(torch.__version__)\n",
|
| 780 |
+
"print(torch.version.cuda)"
|
| 781 |
+
],
|
| 782 |
+
"metadata": {
|
| 783 |
+
"id": "Ev9PEUdtpEAx",
|
| 784 |
+
"colab": {
|
| 785 |
+
"base_uri": "https://localhost:8080/"
|
| 786 |
+
},
|
| 787 |
+
"outputId": "8a338177-81b6-46b8-de3c-e3870f0cfb7c"
|
| 788 |
+
},
|
| 789 |
+
"id": "Ev9PEUdtpEAx",
|
| 790 |
+
"execution_count": 23,
|
| 791 |
+
"outputs": [
|
| 792 |
+
{
|
| 793 |
+
"output_type": "stream",
|
| 794 |
+
"name": "stdout",
|
| 795 |
+
"text": [
|
| 796 |
+
"nvcc: NVIDIA (R) Cuda compiler driver\n",
|
| 797 |
+
"Copyright (c) 2005-2025 NVIDIA Corporation\n",
|
| 798 |
+
"Built on Fri_Feb_21_20:23:50_PST_2025\n",
|
| 799 |
+
"Cuda compilation tools, release 12.8, V12.8.93\n",
|
| 800 |
+
"Build cuda_12.8.r12.8/compiler.35583870_0\n",
|
| 801 |
+
"2.9.0+cu128\n",
|
| 802 |
+
"12.8\n"
|
| 803 |
+
]
|
| 804 |
+
}
|
| 805 |
+
]
|
| 806 |
+
},
|
| 807 |
+
{
|
| 808 |
+
"cell_type": "code",
|
| 809 |
+
"execution_count": 24,
|
| 810 |
+
"id": "b8690389",
|
| 811 |
+
"metadata": {
|
| 812 |
+
"execution": {
|
| 813 |
+
"iopub.execute_input": "2026-01-10T18:22:43.739411Z",
|
| 814 |
+
"iopub.status.busy": "2026-01-10T18:22:43.738855Z",
|
| 815 |
+
"iopub.status.idle": "2026-01-10T18:22:43.755664Z",
|
| 816 |
+
"shell.execute_reply": "2026-01-10T18:22:43.754865Z"
|
| 817 |
+
},
|
| 818 |
+
"papermill": {
|
| 819 |
+
"duration": 0.027297,
|
| 820 |
+
"end_time": "2026-01-10T18:22:43.756758",
|
| 821 |
+
"exception": false,
|
| 822 |
+
"start_time": "2026-01-10T18:22:43.729461",
|
| 823 |
+
"status": "completed"
|
| 824 |
+
},
|
| 825 |
+
"tags": [],
|
| 826 |
+
"id": "b8690389"
|
| 827 |
+
},
|
| 828 |
+
"outputs": [],
|
| 829 |
+
"source": [
|
| 830 |
+
"import os\n",
|
| 831 |
+
"import glob\n",
|
| 832 |
+
"import cv2\n",
|
| 833 |
+
"import numpy as np\n",
|
| 834 |
+
"from PIL import Image\n",
|
| 835 |
+
"\n",
|
| 836 |
+
"# =========================================================\n",
|
| 837 |
+
"# Utility: aspect ratio preserved + black padding\n",
|
| 838 |
+
"# =========================================================\n",
|
| 839 |
+
"\n",
|
| 840 |
+
"def normalize_image_sizes_biplet(input_dir, output_dir=None, size=1024, max_images=None):\n",
|
| 841 |
+
" \"\"\"\n",
|
| 842 |
+
" Generates two square crops (Left & Right or Top & Bottom)\n",
|
| 843 |
+
" from each image in a directory and returns the output directory\n",
|
| 844 |
+
" and the list of generated file paths.\n",
|
| 845 |
+
"\n",
|
| 846 |
+
" Args:\n",
|
| 847 |
+
" input_dir: Input directory containing source images\n",
|
| 848 |
+
" output_dir: Output directory for processed images\n",
|
| 849 |
+
" size: Target square size (default: 1024)\n",
|
| 850 |
+
" max_images: Maximum number of SOURCE images to process (default: None = all images)\n",
|
| 851 |
+
" \"\"\"\n",
|
| 852 |
+
" if output_dir is None:\n",
|
| 853 |
+
" output_dir = 'output/images_biplet'\n",
|
| 854 |
+
" os.makedirs(output_dir, exist_ok=True)\n",
|
| 855 |
+
"\n",
|
| 856 |
+
" print(f\"--- Step 1: Biplet-Square Normalization ---\")\n",
|
| 857 |
+
" print(f\"Generating 2 cropped squares (Left/Right or Top/Bottom) for each image...\")\n",
|
| 858 |
+
" print()\n",
|
| 859 |
+
"\n",
|
| 860 |
+
" generated_paths = []\n",
|
| 861 |
+
" converted_count = 0\n",
|
| 862 |
+
" size_stats = {}\n",
|
| 863 |
+
"\n",
|
| 864 |
+
" # Sort for consistent processing order\n",
|
| 865 |
+
" image_files = sorted([f for f in os.listdir(input_dir)\n",
|
| 866 |
+
" if f.lower().endswith(('.jpg', '.jpeg', '.png'))])\n",
|
| 867 |
+
"\n",
|
| 868 |
+
" # โ
max_images ใงๅ
็ปๅๆฐใๅถ้\n",
|
| 869 |
+
" if max_images is not None:\n",
|
| 870 |
+
" image_files = image_files[:max_images]\n",
|
| 871 |
+
" print(f\"Processing limited to {max_images} source images (will generate {max_images * 2} cropped images)\")\n",
|
| 872 |
+
"\n",
|
| 873 |
+
" for img_file in image_files:\n",
|
| 874 |
+
" input_path = os.path.join(input_dir, img_file)\n",
|
| 875 |
+
" try:\n",
|
| 876 |
+
" img = Image.open(input_path)\n",
|
| 877 |
+
" original_size = img.size\n",
|
| 878 |
+
"\n",
|
| 879 |
+
" # Tracking original aspect ratios\n",
|
| 880 |
+
" size_key = f\"{original_size[0]}x{original_size[1]}\"\n",
|
| 881 |
+
" size_stats[size_key] = size_stats.get(size_key, 0) + 1\n",
|
| 882 |
+
"\n",
|
| 883 |
+
" # Generate 2 crops using the helper function\n",
|
| 884 |
+
" crops = generate_two_crops(img, size)\n",
|
| 885 |
+
" base_name, ext = os.path.splitext(img_file)\n",
|
| 886 |
+
"\n",
|
| 887 |
+
" for mode, cropped_img in crops.items():\n",
|
| 888 |
+
" output_path = os.path.join(output_dir, f\"{base_name}_{mode}{ext}\")\n",
|
| 889 |
+
" cropped_img.save(output_path, quality=95)\n",
|
| 890 |
+
" generated_paths.append(output_path)\n",
|
| 891 |
+
"\n",
|
| 892 |
+
" converted_count += 1\n",
|
| 893 |
+
" print(f\" โ {img_file}: {original_size} โ 2 square images generated\")\n",
|
| 894 |
+
"\n",
|
| 895 |
+
" except Exception as e:\n",
|
| 896 |
+
" print(f\" โ Error processing {img_file}: {e}\")\n",
|
| 897 |
+
"\n",
|
| 898 |
+
" print(f\"\\nProcessing complete: {converted_count} source images processed\")\n",
|
| 899 |
+
" print(f\"Total output images: {len(generated_paths)}\")\n",
|
| 900 |
+
" print(f\"Original size distribution: {size_stats}\")\n",
|
| 901 |
+
"\n",
|
| 902 |
+
" return output_dir, generated_paths\n",
|
| 903 |
+
"\n",
|
| 904 |
+
"\n",
|
| 905 |
+
"def generate_two_crops(img, size):\n",
|
| 906 |
+
" \"\"\"\n",
|
| 907 |
+
" Crops the image into a square and returns 2 variations\n",
|
| 908 |
+
" (Left/Right for landscape, Top/Bottom for portrait).\n",
|
| 909 |
+
" \"\"\"\n",
|
| 910 |
+
" width, height = img.size\n",
|
| 911 |
+
" crop_size = min(width, height)\n",
|
| 912 |
+
" crops = {}\n",
|
| 913 |
+
"\n",
|
| 914 |
+
" if width > height:\n",
|
| 915 |
+
" # Landscape โ Left & Right\n",
|
| 916 |
+
" positions = {\n",
|
| 917 |
+
" 'left': 0,\n",
|
| 918 |
+
" 'right': width - crop_size\n",
|
| 919 |
+
" }\n",
|
| 920 |
+
" for mode, x_offset in positions.items():\n",
|
| 921 |
+
" box = (x_offset, 0, x_offset + crop_size, crop_size)\n",
|
| 922 |
+
" crops[mode] = img.crop(box).resize(\n",
|
| 923 |
+
" (size, size),\n",
|
| 924 |
+
" Image.Resampling.LANCZOS\n",
|
| 925 |
+
" )\n",
|
| 926 |
+
"\n",
|
| 927 |
+
" else:\n",
|
| 928 |
+
" # Portrait or Square โ Top & Bottom\n",
|
| 929 |
+
" positions = {\n",
|
| 930 |
+
" 'top': 0,\n",
|
| 931 |
+
" 'bottom': height - crop_size\n",
|
| 932 |
+
" }\n",
|
| 933 |
+
" for mode, y_offset in positions.items():\n",
|
| 934 |
+
" box = (0, y_offset, crop_size, y_offset + crop_size)\n",
|
| 935 |
+
" crops[mode] = img.crop(box).resize(\n",
|
| 936 |
+
" (size, size),\n",
|
| 937 |
+
" Image.Resampling.LANCZOS\n",
|
| 938 |
+
" )\n",
|
| 939 |
+
"\n",
|
| 940 |
+
" return crops\n"
|
| 941 |
+
]
|
| 942 |
+
},
|
| 943 |
+
{
|
| 944 |
+
"cell_type": "code",
|
| 945 |
+
"execution_count": 25,
|
| 946 |
+
"id": "7acc20b6",
|
| 947 |
+
"metadata": {
|
| 948 |
+
"execution": {
|
| 949 |
+
"iopub.execute_input": "2026-01-10T18:22:43.772525Z",
|
| 950 |
+
"iopub.status.busy": "2026-01-10T18:22:43.772303Z",
|
| 951 |
+
"iopub.status.idle": "2026-01-10T18:22:43.790574Z",
|
| 952 |
+
"shell.execute_reply": "2026-01-10T18:22:43.789515Z"
|
| 953 |
+
},
|
| 954 |
+
"papermill": {
|
| 955 |
+
"duration": 0.027612,
|
| 956 |
+
"end_time": "2026-01-10T18:22:43.791681",
|
| 957 |
+
"exception": false,
|
| 958 |
+
"start_time": "2026-01-10T18:22:43.764069",
|
| 959 |
+
"status": "completed"
|
| 960 |
+
},
|
| 961 |
+
"tags": [],
|
| 962 |
+
"id": "7acc20b6"
|
| 963 |
+
},
|
| 964 |
+
"outputs": [],
|
| 965 |
+
"source": [
|
| 966 |
+
"def run_colmap_reconstruction(image_dir, colmap_dir):\n",
|
| 967 |
+
" \"\"\"Estimate camera poses and 3D point cloud with COLMAP\"\"\"\n",
|
| 968 |
+
" print(\"Running SfM reconstruction with COLMAP...\")\n",
|
| 969 |
+
"\n",
|
| 970 |
+
" database_path = os.path.join(colmap_dir, \"database.db\")\n",
|
| 971 |
+
" sparse_dir = os.path.join(colmap_dir, \"sparse\")\n",
|
| 972 |
+
" os.makedirs(sparse_dir, exist_ok=True)\n",
|
| 973 |
+
"\n",
|
| 974 |
+
" # Set environment variable\n",
|
| 975 |
+
" env = os.environ.copy()\n",
|
| 976 |
+
" env['QT_QPA_PLATFORM'] = 'offscreen'\n",
|
| 977 |
+
"\n",
|
| 978 |
+
" # Feature extraction\n",
|
| 979 |
+
" print(\"1/4: Extracting features...\")\n",
|
| 980 |
+
" subprocess.run([\n",
|
| 981 |
+
" 'colmap', 'feature_extractor',\n",
|
| 982 |
+
" '--database_path', database_path,\n",
|
| 983 |
+
" '--image_path', image_dir,\n",
|
| 984 |
+
" '--ImageReader.single_camera', '1',\n",
|
| 985 |
+
" '--ImageReader.camera_model', 'OPENCV',\n",
|
| 986 |
+
" '--SiftExtraction.use_gpu', '0' # Use CPU\n",
|
| 987 |
+
" ], check=True, env=env)\n",
|
| 988 |
+
"\n",
|
| 989 |
+
" # Feature matching\n",
|
| 990 |
+
" print(\"2/4: Matching features...\")\n",
|
| 991 |
+
" subprocess.run([\n",
|
| 992 |
+
" 'colmap', 'exhaustive_matcher', # Use sequential_matcher instead of exhaustive_matcher\n",
|
| 993 |
+
" '--database_path', database_path,\n",
|
| 994 |
+
" '--SiftMatching.use_gpu', '0' # Use CPU\n",
|
| 995 |
+
" ], check=True, env=env)\n",
|
| 996 |
+
"\n",
|
| 997 |
+
" # Sparse reconstruction\n",
|
| 998 |
+
" print(\"3/4: Sparse reconstruction...\")\n",
|
| 999 |
+
" subprocess.run([\n",
|
| 1000 |
+
" 'colmap', 'mapper',\n",
|
| 1001 |
+
" '--database_path', database_path,\n",
|
| 1002 |
+
" '--image_path', image_dir,\n",
|
| 1003 |
+
" '--output_path', sparse_dir,\n",
|
| 1004 |
+
" '--Mapper.ba_global_max_num_iterations', '20', # Speed up\n",
|
| 1005 |
+
" '--Mapper.ba_local_max_num_iterations', '10'\n",
|
| 1006 |
+
" ], check=True, env=env)\n",
|
| 1007 |
+
"\n",
|
| 1008 |
+
" # Export to text format\n",
|
| 1009 |
+
" print(\"4/4: Exporting to text format...\")\n",
|
| 1010 |
+
" model_dir = os.path.join(sparse_dir, '0')\n",
|
| 1011 |
+
" if not os.path.exists(model_dir):\n",
|
| 1012 |
+
" # Use the first model found\n",
|
| 1013 |
+
" subdirs = [d for d in os.listdir(sparse_dir) if os.path.isdir(os.path.join(sparse_dir, d))]\n",
|
| 1014 |
+
" if subdirs:\n",
|
| 1015 |
+
" model_dir = os.path.join(sparse_dir, subdirs[0])\n",
|
| 1016 |
+
" else:\n",
|
| 1017 |
+
" raise FileNotFoundError(\"COLMAP reconstruction failed\")\n",
|
| 1018 |
+
"\n",
|
| 1019 |
+
" subprocess.run([\n",
|
| 1020 |
+
" 'colmap', 'model_converter',\n",
|
| 1021 |
+
" '--input_path', model_dir,\n",
|
| 1022 |
+
" '--output_path', model_dir,\n",
|
| 1023 |
+
" '--output_type', 'TXT'\n",
|
| 1024 |
+
" ], check=True, env=env)\n",
|
| 1025 |
+
"\n",
|
| 1026 |
+
" print(f\"COLMAP reconstruction complete: {model_dir}\")\n",
|
| 1027 |
+
" return model_dir\n",
|
| 1028 |
+
"\n",
|
| 1029 |
+
"\n",
|
| 1030 |
+
"def convert_cameras_to_pinhole(input_file, output_file):\n",
|
| 1031 |
+
" \"\"\"Convert camera model to PINHOLE format\"\"\"\n",
|
| 1032 |
+
" print(f\"Reading camera file: {input_file}\")\n",
|
| 1033 |
+
"\n",
|
| 1034 |
+
" with open(input_file, 'r') as f:\n",
|
| 1035 |
+
" lines = f.readlines()\n",
|
| 1036 |
+
"\n",
|
| 1037 |
+
" converted_count = 0\n",
|
| 1038 |
+
" with open(output_file, 'w') as f:\n",
|
| 1039 |
+
" for line in lines:\n",
|
| 1040 |
+
" if line.startswith('#') or line.strip() == '':\n",
|
| 1041 |
+
" f.write(line)\n",
|
| 1042 |
+
" else:\n",
|
| 1043 |
+
" parts = line.strip().split()\n",
|
| 1044 |
+
" if len(parts) >= 4:\n",
|
| 1045 |
+
" cam_id = parts[0]\n",
|
| 1046 |
+
" model = parts[1]\n",
|
| 1047 |
+
" width = parts[2]\n",
|
| 1048 |
+
" height = parts[3]\n",
|
| 1049 |
+
" params = parts[4:]\n",
|
| 1050 |
+
"\n",
|
| 1051 |
+
" # Convert to PINHOLE format\n",
|
| 1052 |
+
" if model == \"PINHOLE\":\n",
|
| 1053 |
+
" f.write(line)\n",
|
| 1054 |
+
" elif model == \"OPENCV\":\n",
|
| 1055 |
+
" # OPENCV: fx, fy, cx, cy, k1, k2, p1, p2\n",
|
| 1056 |
+
" fx = params[0]\n",
|
| 1057 |
+
" fy = params[1]\n",
|
| 1058 |
+
" cx = params[2]\n",
|
| 1059 |
+
" cy = params[3]\n",
|
| 1060 |
+
" f.write(f\"{cam_id} PINHOLE {width} {height} {fx} {fy} {cx} {cy}\\n\")\n",
|
| 1061 |
+
" converted_count += 1\n",
|
| 1062 |
+
" else:\n",
|
| 1063 |
+
" # Convert other models too\n",
|
| 1064 |
+
" fx = fy = max(float(width), float(height))\n",
|
| 1065 |
+
" cx = float(width) / 2\n",
|
| 1066 |
+
" cy = float(height) / 2\n",
|
| 1067 |
+
" f.write(f\"{cam_id} PINHOLE {width} {height} {fx} {fy} {cx} {cy}\\n\")\n",
|
| 1068 |
+
" converted_count += 1\n",
|
| 1069 |
+
" else:\n",
|
| 1070 |
+
" f.write(line)\n",
|
| 1071 |
+
"\n",
|
| 1072 |
+
" print(f\"Converted {converted_count} cameras to PINHOLE format\")\n",
|
| 1073 |
+
"\n",
|
| 1074 |
+
"\n",
|
| 1075 |
+
"def prepare_gaussian_splatting_data(image_dir, colmap_model_dir):\n",
|
| 1076 |
+
" \"\"\"Prepare data for Gaussian Splatting\"\"\"\n",
|
| 1077 |
+
" print(\"Preparing data for Gaussian Splatting...\")\n",
|
| 1078 |
+
"\n",
|
| 1079 |
+
" data_dir = f\"{WORK_DIR}/data/video\"\n",
|
| 1080 |
+
" os.makedirs(f\"{data_dir}/sparse/0\", exist_ok=True)\n",
|
| 1081 |
+
" os.makedirs(f\"{data_dir}/images\", exist_ok=True)\n",
|
| 1082 |
+
"\n",
|
| 1083 |
+
" # Copy images\n",
|
| 1084 |
+
" print(\"Copying images...\")\n",
|
| 1085 |
+
" img_count = 0\n",
|
| 1086 |
+
" for img_file in os.listdir(image_dir):\n",
|
| 1087 |
+
" if img_file.lower().endswith(('.jpg', '.jpeg', '.png')):\n",
|
| 1088 |
+
" shutil.copy(\n",
|
| 1089 |
+
" os.path.join(image_dir, img_file),\n",
|
| 1090 |
+
" f\"{data_dir}/images/{img_file}\"\n",
|
| 1091 |
+
" )\n",
|
| 1092 |
+
" img_count += 1\n",
|
| 1093 |
+
" print(f\"Copied {img_count} images\")\n",
|
| 1094 |
+
"\n",
|
| 1095 |
+
" # Convert and copy camera file to PINHOLE format\n",
|
| 1096 |
+
" print(\"Converting camera model to PINHOLE format...\")\n",
|
| 1097 |
+
" convert_cameras_to_pinhole(\n",
|
| 1098 |
+
" os.path.join(colmap_model_dir, 'cameras.txt'),\n",
|
| 1099 |
+
" f\"{data_dir}/sparse/0/cameras.txt\"\n",
|
| 1100 |
+
" )\n",
|
| 1101 |
+
"\n",
|
| 1102 |
+
" # Copy other files\n",
|
| 1103 |
+
" for filename in ['images.txt', 'points3D.txt']:\n",
|
| 1104 |
+
" src = os.path.join(colmap_model_dir, filename)\n",
|
| 1105 |
+
" dst = f\"{data_dir}/sparse/0/{filename}\"\n",
|
| 1106 |
+
" if os.path.exists(src):\n",
|
| 1107 |
+
" shutil.copy(src, dst)\n",
|
| 1108 |
+
" print(f\"Copied {filename}\")\n",
|
| 1109 |
+
" else:\n",
|
| 1110 |
+
" print(f\"Warning: {filename} not found\")\n",
|
| 1111 |
+
"\n",
|
| 1112 |
+
" print(f\"Data preparation complete: {data_dir}\")\n",
|
| 1113 |
+
" return data_dir\n",
|
| 1114 |
+
"\n",
|
| 1115 |
+
"def run_colmap_reconstruction(image_dir, colmap_dir):\n",
|
| 1116 |
+
" \"\"\"Estimate camera poses and 3D point cloud with COLMAP\"\"\"\n",
|
| 1117 |
+
" print(\"Running SfM reconstruction with COLMAP...\")\n",
|
| 1118 |
+
"\n",
|
| 1119 |
+
" database_path = os.path.join(colmap_dir, \"database.db\")\n",
|
| 1120 |
+
" sparse_dir = os.path.join(colmap_dir, \"sparse\")\n",
|
| 1121 |
+
" os.makedirs(sparse_dir, exist_ok=True)\n",
|
| 1122 |
+
"\n",
|
| 1123 |
+
" # Set environment variable\n",
|
| 1124 |
+
" env = os.environ.copy()\n",
|
| 1125 |
+
" env['QT_QPA_PLATFORM'] = 'offscreen'\n",
|
| 1126 |
+
"\n",
|
| 1127 |
+
" # Feature extraction\n",
|
| 1128 |
+
" print(\"1/4: Extracting features...\")\n",
|
| 1129 |
+
" subprocess.run([\n",
|
| 1130 |
+
" 'colmap', 'feature_extractor',\n",
|
| 1131 |
+
" '--database_path', database_path,\n",
|
| 1132 |
+
" '--image_path', image_dir,\n",
|
| 1133 |
+
" '--ImageReader.single_camera', '1',\n",
|
| 1134 |
+
" '--ImageReader.camera_model', 'OPENCV',\n",
|
| 1135 |
+
" '--SiftExtraction.use_gpu', '0' # Use CPU\n",
|
| 1136 |
+
" ], check=True, env=env)\n",
|
| 1137 |
+
"\n",
|
| 1138 |
+
" # Feature matching\n",
|
| 1139 |
+
" print(\"2/4: Matching features...\")\n",
|
| 1140 |
+
" subprocess.run([\n",
|
| 1141 |
+
" 'colmap', 'exhaustive_matcher', # Use sequential_matcher instead of exhaustive_matcher\n",
|
| 1142 |
+
" '--database_path', database_path,\n",
|
| 1143 |
+
" '--SiftMatching.use_gpu', '0' # Use CPU\n",
|
| 1144 |
+
" ], check=True, env=env)\n",
|
| 1145 |
+
"\n",
|
| 1146 |
+
" # Sparse reconstruction\n",
|
| 1147 |
+
" print(\"3/4: Sparse reconstruction...\")\n",
|
| 1148 |
+
" subprocess.run([\n",
|
| 1149 |
+
" 'colmap', 'mapper',\n",
|
| 1150 |
+
" '--database_path', database_path,\n",
|
| 1151 |
+
" '--image_path', image_dir,\n",
|
| 1152 |
+
" '--output_path', sparse_dir,\n",
|
| 1153 |
+
" '--Mapper.ba_global_max_num_iterations', '20', # Speed up\n",
|
| 1154 |
+
" '--Mapper.ba_local_max_num_iterations', '10'\n",
|
| 1155 |
+
" ], check=True, env=env)\n",
|
| 1156 |
+
"\n",
|
| 1157 |
+
" # Export to text format\n",
|
| 1158 |
+
" print(\"4/4: Exporting to text format...\")\n",
|
| 1159 |
+
" model_dir = os.path.join(sparse_dir, '0')\n",
|
| 1160 |
+
" if not os.path.exists(model_dir):\n",
|
| 1161 |
+
" # Use the first model found\n",
|
| 1162 |
+
" subdirs = [d for d in os.listdir(sparse_dir) if os.path.isdir(os.path.join(sparse_dir, d))]\n",
|
| 1163 |
+
" if subdirs:\n",
|
| 1164 |
+
" model_dir = os.path.join(sparse_dir, subdirs[0])\n",
|
| 1165 |
+
" else:\n",
|
| 1166 |
+
" raise FileNotFoundError(\"COLMAP reconstruction failed\")\n",
|
| 1167 |
+
"\n",
|
| 1168 |
+
" subprocess.run([\n",
|
| 1169 |
+
" 'colmap', 'model_converter',\n",
|
| 1170 |
+
" '--input_path', model_dir,\n",
|
| 1171 |
+
" '--output_path', model_dir,\n",
|
| 1172 |
+
" '--output_type', 'TXT'\n",
|
| 1173 |
+
" ], check=True, env=env)\n",
|
| 1174 |
+
"\n",
|
| 1175 |
+
" print(f\"COLMAP reconstruction complete: {model_dir}\")\n",
|
| 1176 |
+
" return model_dir\n",
|
| 1177 |
+
"\n",
|
| 1178 |
+
"\n",
|
| 1179 |
+
"def convert_cameras_to_pinhole(input_file, output_file):\n",
|
| 1180 |
+
" \"\"\"Convert camera model to PINHOLE format\"\"\"\n",
|
| 1181 |
+
" print(f\"Reading camera file: {input_file}\")\n",
|
| 1182 |
+
"\n",
|
| 1183 |
+
" with open(input_file, 'r') as f:\n",
|
| 1184 |
+
" lines = f.readlines()\n",
|
| 1185 |
+
"\n",
|
| 1186 |
+
" converted_count = 0\n",
|
| 1187 |
+
" with open(output_file, 'w') as f:\n",
|
| 1188 |
+
" for line in lines:\n",
|
| 1189 |
+
" if line.startswith('#') or line.strip() == '':\n",
|
| 1190 |
+
" f.write(line)\n",
|
| 1191 |
+
" else:\n",
|
| 1192 |
+
" parts = line.strip().split()\n",
|
| 1193 |
+
" if len(parts) >= 4:\n",
|
| 1194 |
+
" cam_id = parts[0]\n",
|
| 1195 |
+
" model = parts[1]\n",
|
| 1196 |
+
" width = parts[2]\n",
|
| 1197 |
+
" height = parts[3]\n",
|
| 1198 |
+
" params = parts[4:]\n",
|
| 1199 |
+
"\n",
|
| 1200 |
+
" # Convert to PINHOLE format\n",
|
| 1201 |
+
" if model == \"PINHOLE\":\n",
|
| 1202 |
+
" f.write(line)\n",
|
| 1203 |
+
" elif model == \"OPENCV\":\n",
|
| 1204 |
+
" # OPENCV: fx, fy, cx, cy, k1, k2, p1, p2\n",
|
| 1205 |
+
" fx = params[0]\n",
|
| 1206 |
+
" fy = params[1]\n",
|
| 1207 |
+
" cx = params[2]\n",
|
| 1208 |
+
" cy = params[3]\n",
|
| 1209 |
+
" f.write(f\"{cam_id} PINHOLE {width} {height} {fx} {fy} {cx} {cy}\\n\")\n",
|
| 1210 |
+
" converted_count += 1\n",
|
| 1211 |
+
" else:\n",
|
| 1212 |
+
" # Convert other models too\n",
|
| 1213 |
+
" fx = fy = max(float(width), float(height))\n",
|
| 1214 |
+
" cx = float(width) / 2\n",
|
| 1215 |
+
" cy = float(height) / 2\n",
|
| 1216 |
+
" f.write(f\"{cam_id} PINHOLE {width} {height} {fx} {fy} {cx} {cy}\\n\")\n",
|
| 1217 |
+
" converted_count += 1\n",
|
| 1218 |
+
" else:\n",
|
| 1219 |
+
" f.write(line)\n",
|
| 1220 |
+
"\n",
|
| 1221 |
+
" print(f\"Converted {converted_count} cameras to PINHOLE format\")\n",
|
| 1222 |
+
"\n",
|
| 1223 |
+
"\n",
|
| 1224 |
+
"def prepare_gaussian_splatting_data(image_dir, colmap_model_dir):\n",
|
| 1225 |
+
" \"\"\"Prepare data for Gaussian Splatting\"\"\"\n",
|
| 1226 |
+
" print(\"Preparing data for Gaussian Splatting...\")\n",
|
| 1227 |
+
"\n",
|
| 1228 |
+
" data_dir = f\"{WORK_DIR}/data/video\"\n",
|
| 1229 |
+
" os.makedirs(f\"{data_dir}/sparse/0\", exist_ok=True)\n",
|
| 1230 |
+
" os.makedirs(f\"{data_dir}/images\", exist_ok=True)\n",
|
| 1231 |
+
"\n",
|
| 1232 |
+
" # Copy images\n",
|
| 1233 |
+
" print(\"Copying images...\")\n",
|
| 1234 |
+
" img_count = 0\n",
|
| 1235 |
+
" for img_file in os.listdir(image_dir):\n",
|
| 1236 |
+
" if img_file.lower().endswith(('.jpg', '.jpeg', '.png')):\n",
|
| 1237 |
+
" shutil.copy(\n",
|
| 1238 |
+
" os.path.join(image_dir, img_file),\n",
|
| 1239 |
+
" f\"{data_dir}/images/{img_file}\"\n",
|
| 1240 |
+
" )\n",
|
| 1241 |
+
" img_count += 1\n",
|
| 1242 |
+
" print(f\"Copied {img_count} images\")\n",
|
| 1243 |
+
"\n",
|
| 1244 |
+
" # Convert and copy camera file to PINHOLE format\n",
|
| 1245 |
+
" print(\"Converting camera model to PINHOLE format...\")\n",
|
| 1246 |
+
" convert_cameras_to_pinhole(\n",
|
| 1247 |
+
" os.path.join(colmap_model_dir, 'cameras.txt'),\n",
|
| 1248 |
+
" f\"{data_dir}/sparse/0/cameras.txt\"\n",
|
| 1249 |
+
" )\n",
|
| 1250 |
+
"\n",
|
| 1251 |
+
" # Copy other files\n",
|
| 1252 |
+
" for filename in ['images.txt', 'points3D.txt']:\n",
|
| 1253 |
+
" src = os.path.join(colmap_model_dir, filename)\n",
|
| 1254 |
+
" dst = f\"{data_dir}/sparse/0/{filename}\"\n",
|
| 1255 |
+
" if os.path.exists(src):\n",
|
| 1256 |
+
" shutil.copy(src, dst)\n",
|
| 1257 |
+
" print(f\"Copied {filename}\")\n",
|
| 1258 |
+
" else:\n",
|
| 1259 |
+
" print(f\"Warning: {filename} not found\")\n",
|
| 1260 |
+
"\n",
|
| 1261 |
+
" print(f\"Data preparation complete: {data_dir}\")\n",
|
| 1262 |
+
" return data_dir\n",
|
| 1263 |
+
"\n",
|
| 1264 |
+
"\n",
|
| 1265 |
+
"\n",
|
| 1266 |
+
"###############################################################\n",
|
| 1267 |
+
"\n",
|
| 1268 |
+
"# ๅคๆดๅพ (2DGS) - ๆญฃๅๅใใฉใกใผใฟใ่ฟฝๅ \n",
|
| 1269 |
+
"def train_gaussian_splatting(data_dir, iterations=7000,\n",
|
| 1270 |
+
" lambda_normal=0.05,\n",
|
| 1271 |
+
" lambda_dist=0, # โ distortion โ dist ใซไฟฎๆญฃ\n",
|
| 1272 |
+
" depth_ratio=0):\n",
|
| 1273 |
+
" \"\"\"\n",
|
| 1274 |
+
" 2DGS็จใฎใใฌใผใใณใฐ้ขๆฐ\n",
|
| 1275 |
+
" Args:\n",
|
| 1276 |
+
" lambda_normal: ๆณ็ทไธ่ฒซๆงใฎ้ใฟ (ใใใฉใซใ: 0.05)\n",
|
| 1277 |
+
" lambda_dist: ๆทฑๅบฆๆญชใฟใฎ้ใฟ (ใใใฉใซใ: 0) # โ ๅๅไฟฎๆญฃ\n",
|
| 1278 |
+
" depth_ratio: 0=ๅนณๅๆทฑๅบฆ, 1=ไธญๅคฎๅคๆทฑๅบฆ (ใใใฉใซใ: 0)\n",
|
| 1279 |
+
" \"\"\"\n",
|
| 1280 |
+
" model_path = f\"{WORK_DIR}/output/video\"\n",
|
| 1281 |
+
" cmd = [\n",
|
| 1282 |
+
" sys.executable, 'train.py',\n",
|
| 1283 |
+
" '-s', data_dir,\n",
|
| 1284 |
+
" '-m', model_path,\n",
|
| 1285 |
+
" '--iterations', str(iterations),\n",
|
| 1286 |
+
" '--lambda_normal', str(lambda_normal),\n",
|
| 1287 |
+
" '--lambda_dist', str(lambda_dist), # โ ใใใไฟฎๆญฃ๏ผ\n",
|
| 1288 |
+
" '--depth_ratio', str(depth_ratio),\n",
|
| 1289 |
+
" '--eval'\n",
|
| 1290 |
+
" ]\n",
|
| 1291 |
+
" subprocess.run(cmd, cwd=WORK_DIR, check=True)\n",
|
| 1292 |
+
" return model_path\n",
|
| 1293 |
+
"\n",
|
| 1294 |
+
"\n",
|
| 1295 |
+
"\n",
|
| 1296 |
+
"# 2DGSใงใฏใกใใทใฅๆฝๅบใชใใทใงใณใ่ฟฝๅ ใใใฆใใพใ\n",
|
| 1297 |
+
"def render_video_and_mesh(model_path, output_video_path, iteration=1000,\n",
|
| 1298 |
+
" extract_mesh=False, unbounded=False, mesh_res=1024):\n",
|
| 1299 |
+
" \"\"\"\n",
|
| 1300 |
+
" 2DGS็จใฎใฌใณใใชใณใฐใจใกใใทใฅๆฝๅบ\n",
|
| 1301 |
+
" Args:\n",
|
| 1302 |
+
" extract_mesh: ใกใใทใฅใๆฝๅบใใใ (ใใใฉใซใ: Falseใๅ็ปใฎใฟ)\n",
|
| 1303 |
+
" unbounded: ๅข็ใชใใกใใทใฅๆฝๅบใไฝฟ็จใใใ\n",
|
| 1304 |
+
" mesh_res: ใกใใทใฅ่งฃๅๅบฆ\n",
|
| 1305 |
+
" \"\"\"\n",
|
| 1306 |
+
" # ้ๅธธใฎใฌใณใใชใณใฐ\n",
|
| 1307 |
+
" cmd = [\n",
|
| 1308 |
+
" sys.executable, 'render.py',\n",
|
| 1309 |
+
" '-m', model_path,\n",
|
| 1310 |
+
" '--iteration', str(iteration),\n",
|
| 1311 |
+
" '--skip_test',\n",
|
| 1312 |
+
" '--skip_train'\n",
|
| 1313 |
+
" ]\n",
|
| 1314 |
+
"\n",
|
| 1315 |
+
" # ใกใใทใฅๆฝๅบใชใใทใงใณ๏ผๅฟ
่ฆใชๅ ดๅใฎใฟ๏ผ\n",
|
| 1316 |
+
" if extract_mesh:\n",
|
| 1317 |
+
" if unbounded:\n",
|
| 1318 |
+
" cmd.extend(['--unbounded'])\n",
|
| 1319 |
+
" cmd.extend(['--mesh_res', str(mesh_res)])\n",
|
| 1320 |
+
"\n",
|
| 1321 |
+
" # ใจใฉใผ่ฉณ็ดฐใใญใฃใใใฃ\n",
|
| 1322 |
+
" result = subprocess.run(\n",
|
| 1323 |
+
" cmd,\n",
|
| 1324 |
+
" cwd=WORK_DIR,\n",
|
| 1325 |
+
" capture_output=True,\n",
|
| 1326 |
+
" text=True\n",
|
| 1327 |
+
" )\n",
|
| 1328 |
+
"\n",
|
| 1329 |
+
" if result.returncode != 0:\n",
|
| 1330 |
+
" print(\"โ STDOUT:\", result.stdout)\n",
|
| 1331 |
+
" print(\"โ STDERR:\", result.stderr)\n",
|
| 1332 |
+
" raise subprocess.CalledProcessError(\n",
|
| 1333 |
+
" result.returncode, cmd, result.stdout, result.stderr\n",
|
| 1334 |
+
" )\n",
|
| 1335 |
+
"\n",
|
| 1336 |
+
" # ใฌใณใใชใณใฐ็ตๆใใใใใชไฝๆ\n",
|
| 1337 |
+
" possible_dirs = [\n",
|
| 1338 |
+
" f\"{model_path}/test/ours_{iteration}/renders\",\n",
|
| 1339 |
+
" f\"{model_path}/train/ours_{iteration}/renders\",\n",
|
| 1340 |
+
" ]\n",
|
| 1341 |
+
"\n",
|
| 1342 |
+
" render_dir = None\n",
|
| 1343 |
+
" for test_dir in possible_dirs:\n",
|
| 1344 |
+
" if os.path.exists(test_dir):\n",
|
| 1345 |
+
" render_dir = test_dir\n",
|
| 1346 |
+
" print(f\"โ
Rendering directory found: {render_dir}\")\n",
|
| 1347 |
+
" break\n",
|
| 1348 |
+
"\n",
|
| 1349 |
+
" if render_dir and os.path.exists(render_dir):\n",
|
| 1350 |
+
" render_imgs = sorted([f for f in os.listdir(render_dir)\n",
|
| 1351 |
+
" if f.endswith('.png')])\n",
|
| 1352 |
+
" if render_imgs:\n",
|
| 1353 |
+
" print(f\"Found {len(render_imgs)} rendered images\")\n",
|
| 1354 |
+
" # ffmpegใงใใใชไฝๆ\n",
|
| 1355 |
+
" subprocess.run([\n",
|
| 1356 |
+
" 'ffmpeg', '-y',\n",
|
| 1357 |
+
" '-framerate', '30',\n",
|
| 1358 |
+
" '-pattern_type', 'glob',\n",
|
| 1359 |
+
" '-i', f\"{render_dir}/*.png\",\n",
|
| 1360 |
+
" '-c:v', 'libx264',\n",
|
| 1361 |
+
" '-pix_fmt', 'yuv420p',\n",
|
| 1362 |
+
" '-crf', '18',\n",
|
| 1363 |
+
" output_video_path\n",
|
| 1364 |
+
" ], check=True)\n",
|
| 1365 |
+
" print(f\"โ
Video saved: {output_video_path}\")\n",
|
| 1366 |
+
" return True\n",
|
| 1367 |
+
"\n",
|
| 1368 |
+
" print(\"โ Error: Rendering directory not found\")\n",
|
| 1369 |
+
" return False\n",
|
| 1370 |
+
"\n",
|
| 1371 |
+
"\n",
|
| 1372 |
+
"\n",
|
| 1373 |
+
"###############################################################\n",
|
| 1374 |
+
"\n",
|
| 1375 |
+
"\n",
|
| 1376 |
+
"def create_gif(video_path, gif_path):\n",
|
| 1377 |
+
" \"\"\"Create GIF from MP4\"\"\"\n",
|
| 1378 |
+
" print(\"Creating animated GIF...\")\n",
|
| 1379 |
+
"\n",
|
| 1380 |
+
" subprocess.run([\n",
|
| 1381 |
+
" 'ffmpeg', '-y',\n",
|
| 1382 |
+
" '-i', video_path,\n",
|
| 1383 |
+
" '-vf', 'setpts=8*PTS,fps=10,scale=720:-1:flags=lanczos',\n",
|
| 1384 |
+
" '-loop', '0',\n",
|
| 1385 |
+
" gif_path\n",
|
| 1386 |
+
" ], check=True)\n",
|
| 1387 |
+
"\n",
|
| 1388 |
+
" if os.path.exists(gif_path):\n",
|
| 1389 |
+
" size_mb = os.path.getsize(gif_path) / (1024 * 1024)\n",
|
| 1390 |
+
" print(f\"GIF creation complete: {gif_path} ({size_mb:.2f} MB)\")\n",
|
| 1391 |
+
" return True\n",
|
| 1392 |
+
"\n",
|
| 1393 |
+
" return False\n",
|
| 1394 |
+
"\n",
|
| 1395 |
+
""
|
| 1396 |
+
]
|
| 1397 |
+
},
|
| 1398 |
+
{
|
| 1399 |
+
"cell_type": "code",
|
| 1400 |
+
"source": [
|
| 1401 |
+
"WORK_DIR = \"/content/2d-gaussian-splatting\""
|
| 1402 |
+
],
|
| 1403 |
+
"metadata": {
|
| 1404 |
+
"id": "YtqhBP4T3jEH"
|
| 1405 |
+
},
|
| 1406 |
+
"id": "YtqhBP4T3jEH",
|
| 1407 |
+
"execution_count": 26,
|
| 1408 |
+
"outputs": []
|
| 1409 |
+
},
|
| 1410 |
+
{
|
| 1411 |
+
"cell_type": "code",
|
| 1412 |
+
"source": [
|
| 1413 |
+
"def main_pipeline(image_dir, output_dir, square_size=1024, max_images=100):\n",
|
| 1414 |
+
" \"\"\"Main execution function\"\"\"\n",
|
| 1415 |
+
" try:\n",
|
| 1416 |
+
" # Step 1: ็ปๅใฎๆญฃ่ฆๅใจๅๅฆ็\n",
|
| 1417 |
+
" print(\"=\"*60)\n",
|
| 1418 |
+
" print(\"Step 1: Normalizing and preprocessing images\")\n",
|
| 1419 |
+
" print(\"=\"*60)\n",
|
| 1420 |
+
"\n",
|
| 1421 |
+
" frame_dir = os.path.join(COLMAP_DIR, \"images\")\n",
|
| 1422 |
+
" os.makedirs(frame_dir, exist_ok=True)\n",
|
| 1423 |
+
"\n",
|
| 1424 |
+
" # ็ปๅใๆญฃ่ฆๅใใฆ็ดๆฅCOLMAPใฎใใฃใฌใฏใใชใซไฟๅญ\n",
|
| 1425 |
+
" num_processed = normalize_image_sizes_biplet(\n",
|
| 1426 |
+
" input_dir=image_dir,\n",
|
| 1427 |
+
" output_dir=frame_dir, # ็ดๆฅcolmap/imagesใซไฟๅญ\n",
|
| 1428 |
+
" size=square_size,\n",
|
| 1429 |
+
" max_images=max_images\n",
|
| 1430 |
+
" )\n",
|
| 1431 |
+
"\n",
|
| 1432 |
+
" print(f\"Processed {num_processed} images\")\n",
|
| 1433 |
+
"\n",
|
| 1434 |
+
" # Step 2: Estimate Camera Info with COLMAP\n",
|
| 1435 |
+
" print(\"=\"*60)\n",
|
| 1436 |
+
" print(\"Step 2: Running COLMAP reconstruction\")\n",
|
| 1437 |
+
" print(\"=\"*60)\n",
|
| 1438 |
+
" colmap_model_dir = run_colmap_reconstruction(frame_dir, COLMAP_DIR)\n",
|
| 1439 |
+
"\n",
|
| 1440 |
+
" # Step 3: Prepare Data for Gaussian Splatting\n",
|
| 1441 |
+
" print(\"=\"*60)\n",
|
| 1442 |
+
" print(\"Step 3: Preparing Gaussian Splatting data\")\n",
|
| 1443 |
+
" print(\"=\"*60)\n",
|
| 1444 |
+
" data_dir = prepare_gaussian_splatting_data(frame_dir, colmap_model_dir)\n",
|
| 1445 |
+
"\n",
|
| 1446 |
+
" # Step 4: Train Model\n",
|
| 1447 |
+
" print(\"=\"*60)\n",
|
| 1448 |
+
" print(\"Step 4: Training Gaussian Splatting model\")\n",
|
| 1449 |
+
" print(\"=\"*60)\n",
|
| 1450 |
+
" # ไฟฎๆญฃ: frame_dir โ data_dir\n",
|
| 1451 |
+
"\n",
|
| 1452 |
+
" # main_pipelineๅ
ใงๅผใณๅบใ้จๅ\n",
|
| 1453 |
+
" model_path = train_gaussian_splatting(\n",
|
| 1454 |
+
" data_dir,\n",
|
| 1455 |
+
" iterations=1000,\n",
|
| 1456 |
+
" lambda_normal=0.05,\n",
|
| 1457 |
+
" lambda_dist=0, # โ distortion โ dist ใซไฟฎๆญฃ\n",
|
| 1458 |
+
" depth_ratio=0\n",
|
| 1459 |
+
" )\n",
|
| 1460 |
+
"\n",
|
| 1461 |
+
" print(f\"Model trained at: {model_path}\")\n",
|
| 1462 |
+
"\n",
|
| 1463 |
+
" ############################################\n",
|
| 1464 |
+
"\n",
|
| 1465 |
+
" except Exception as e: # โ ใใใ่ฟฝๅ \n",
|
| 1466 |
+
" print(f\"โ Pipeline failed: {e}\")\n",
|
| 1467 |
+
" import traceback\n",
|
| 1468 |
+
" traceback.print_exc()\n",
|
| 1469 |
+
" return None\n",
|
| 1470 |
+
"\n",
|
| 1471 |
+
"\n",
|
| 1472 |
+
"if __name__ == \"__main__\":\n",
|
| 1473 |
+
" IMAGE_DIR = \"/content/drive/MyDrive/your_folder/fountain100\"\n",
|
| 1474 |
+
" OUTPUT_DIR = \"/content/output\"\n",
|
| 1475 |
+
" COLMAP_DIR = \"/content/colmap_workspace\"\n",
|
| 1476 |
+
"\n",
|
| 1477 |
+
" # ใทใณใใซใซ1ใคใฎๆปใๅคใ ใ\n",
|
| 1478 |
+
" ply_path = main_pipeline(\n",
|
| 1479 |
+
" image_dir=IMAGE_DIR,\n",
|
| 1480 |
+
" output_dir=OUTPUT_DIR,\n",
|
| 1481 |
+
" square_size=1024,\n",
|
| 1482 |
+
" max_images=20\n",
|
| 1483 |
+
" )\n",
|
| 1484 |
+
"\n",
|
| 1485 |
+
"\n"
|
| 1486 |
+
],
|
| 1487 |
+
"metadata": {
|
| 1488 |
+
"id": "fya3kv62NXM-",
|
| 1489 |
+
"colab": {
|
| 1490 |
+
"base_uri": "https://localhost:8080/"
|
| 1491 |
+
},
|
| 1492 |
+
"outputId": "e0aa12ee-eff2-4509-af22-509e905c8db3"
|
| 1493 |
+
},
|
| 1494 |
+
"id": "fya3kv62NXM-",
|
| 1495 |
+
"execution_count": 27,
|
| 1496 |
+
"outputs": [
|
| 1497 |
+
{
|
| 1498 |
+
"output_type": "stream",
|
| 1499 |
+
"name": "stdout",
|
| 1500 |
+
"text": [
|
| 1501 |
+
"============================================================\n",
|
| 1502 |
+
"Step 1: Normalizing and preprocessing images\n",
|
| 1503 |
+
"============================================================\n",
|
| 1504 |
+
"--- Step 1: Biplet-Square Normalization ---\n",
|
| 1505 |
+
"Generating 2 cropped squares (Left/Right or Top/Bottom) for each image...\n",
|
| 1506 |
+
"\n",
|
| 1507 |
+
"Processing limited to 20 source images (will generate 40 cropped images)\n",
|
| 1508 |
+
" โ image_101.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1509 |
+
" โ image_102.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1510 |
+
" โ image_103.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1511 |
+
" โ image_104.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1512 |
+
" โ image_105.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1513 |
+
" โ image_106.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1514 |
+
" โ image_107.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1515 |
+
" โ image_108.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1516 |
+
" โ image_109.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1517 |
+
" โ image_110.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1518 |
+
" โ image_111.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1519 |
+
" โ image_112.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1520 |
+
" โ image_113.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1521 |
+
" โ image_114.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1522 |
+
" โ image_115.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1523 |
+
" โ image_116.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1524 |
+
" โ image_117.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1525 |
+
" โ image_118.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1526 |
+
" โ image_119.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1527 |
+
" โ image_120.jpeg: (1440, 1920) โ 2 square images generated\n",
|
| 1528 |
+
"\n",
|
| 1529 |
+
"Processing complete: 20 source images processed\n",
|
| 1530 |
+
"Total output images: 40\n",
|
| 1531 |
+
"Original size distribution: {'1440x1920': 20}\n",
|
| 1532 |
+
"Processed ('/content/colmap_workspace/images', ['/content/colmap_workspace/images/image_101_top.jpeg', '/content/colmap_workspace/images/image_101_bottom.jpeg', '/content/colmap_workspace/images/image_102_top.jpeg', '/content/colmap_workspace/images/image_102_bottom.jpeg', '/content/colmap_workspace/images/image_103_top.jpeg', '/content/colmap_workspace/images/image_103_bottom.jpeg', '/content/colmap_workspace/images/image_104_top.jpeg', '/content/colmap_workspace/images/image_104_bottom.jpeg', '/content/colmap_workspace/images/image_105_top.jpeg', '/content/colmap_workspace/images/image_105_bottom.jpeg', '/content/colmap_workspace/images/image_106_top.jpeg', '/content/colmap_workspace/images/image_106_bottom.jpeg', '/content/colmap_workspace/images/image_107_top.jpeg', '/content/colmap_workspace/images/image_107_bottom.jpeg', '/content/colmap_workspace/images/image_108_top.jpeg', '/content/colmap_workspace/images/image_108_bottom.jpeg', '/content/colmap_workspace/images/image_109_top.jpeg', '/content/colmap_workspace/images/image_109_bottom.jpeg', '/content/colmap_workspace/images/image_110_top.jpeg', '/content/colmap_workspace/images/image_110_bottom.jpeg', '/content/colmap_workspace/images/image_111_top.jpeg', '/content/colmap_workspace/images/image_111_bottom.jpeg', '/content/colmap_workspace/images/image_112_top.jpeg', '/content/colmap_workspace/images/image_112_bottom.jpeg', '/content/colmap_workspace/images/image_113_top.jpeg', '/content/colmap_workspace/images/image_113_bottom.jpeg', '/content/colmap_workspace/images/image_114_top.jpeg', '/content/colmap_workspace/images/image_114_bottom.jpeg', '/content/colmap_workspace/images/image_115_top.jpeg', '/content/colmap_workspace/images/image_115_bottom.jpeg', '/content/colmap_workspace/images/image_116_top.jpeg', '/content/colmap_workspace/images/image_116_bottom.jpeg', '/content/colmap_workspace/images/image_117_top.jpeg', '/content/colmap_workspace/images/image_117_bottom.jpeg', '/content/colmap_workspace/images/image_118_top.jpeg', '/content/colmap_workspace/images/image_118_bottom.jpeg', '/content/colmap_workspace/images/image_119_top.jpeg', '/content/colmap_workspace/images/image_119_bottom.jpeg', '/content/colmap_workspace/images/image_120_top.jpeg', '/content/colmap_workspace/images/image_120_bottom.jpeg']) images\n",
|
| 1533 |
+
"============================================================\n",
|
| 1534 |
+
"Step 2: Running COLMAP reconstruction\n",
|
| 1535 |
+
"============================================================\n",
|
| 1536 |
+
"Running SfM reconstruction with COLMAP...\n",
|
| 1537 |
+
"1/4: Extracting features...\n",
|
| 1538 |
+
"2/4: Matching features...\n",
|
| 1539 |
+
"3/4: Sparse reconstruction...\n",
|
| 1540 |
+
"4/4: Exporting to text format...\n",
|
| 1541 |
+
"COLMAP reconstruction complete: /content/colmap_workspace/sparse/0\n",
|
| 1542 |
+
"============================================================\n",
|
| 1543 |
+
"Step 3: Preparing Gaussian Splatting data\n",
|
| 1544 |
+
"============================================================\n",
|
| 1545 |
+
"Preparing data for Gaussian Splatting...\n",
|
| 1546 |
+
"Copying images...\n",
|
| 1547 |
+
"Copied 40 images\n",
|
| 1548 |
+
"Converting camera model to PINHOLE format...\n",
|
| 1549 |
+
"Reading camera file: /content/colmap_workspace/sparse/0/cameras.txt\n",
|
| 1550 |
+
"Converted 2 cameras to PINHOLE format\n",
|
| 1551 |
+
"Copied images.txt\n",
|
| 1552 |
+
"Copied points3D.txt\n",
|
| 1553 |
+
"Data preparation complete: /content/2d-gaussian-splatting/data/video\n",
|
| 1554 |
+
"============================================================\n",
|
| 1555 |
+
"Step 4: Training Gaussian Splatting model\n",
|
| 1556 |
+
"============================================================\n",
|
| 1557 |
+
"Model trained at: /content/2d-gaussian-splatting/output/video\n"
|
| 1558 |
+
]
|
| 1559 |
+
}
|
| 1560 |
+
]
|
| 1561 |
+
},
|
| 1562 |
+
{
|
| 1563 |
+
"cell_type": "code",
|
| 1564 |
+
"source": [],
|
| 1565 |
+
"metadata": {
|
| 1566 |
+
"id": "9GN6Eny2XsAd"
|
| 1567 |
+
},
|
| 1568 |
+
"id": "9GN6Eny2XsAd",
|
| 1569 |
+
"execution_count": 27,
|
| 1570 |
+
"outputs": []
|
| 1571 |
+
},
|
| 1572 |
+
{
|
| 1573 |
+
"cell_type": "code",
|
| 1574 |
+
"source": [],
|
| 1575 |
+
"metadata": {
|
| 1576 |
+
"id": "6RDKHigGWpaB"
|
| 1577 |
+
},
|
| 1578 |
+
"id": "6RDKHigGWpaB",
|
| 1579 |
+
"execution_count": 27,
|
| 1580 |
+
"outputs": []
|
| 1581 |
+
},
|
| 1582 |
+
{
|
| 1583 |
+
"cell_type": "code",
|
| 1584 |
+
"source": [],
|
| 1585 |
+
"metadata": {
|
| 1586 |
+
"id": "JGbsfe-4WpNj"
|
| 1587 |
+
},
|
| 1588 |
+
"id": "JGbsfe-4WpNj",
|
| 1589 |
+
"execution_count": 27,
|
| 1590 |
+
"outputs": []
|
| 1591 |
+
}
|
| 1592 |
+
],
|
| 1593 |
+
"metadata": {
|
| 1594 |
+
"kaggle": {
|
| 1595 |
+
"accelerator": "nvidiaTeslaT4",
|
| 1596 |
+
"dataSources": [
|
| 1597 |
+
{
|
| 1598 |
+
"databundleVersionId": 5447706,
|
| 1599 |
+
"sourceId": 49349,
|
| 1600 |
+
"sourceType": "competition"
|
| 1601 |
+
},
|
| 1602 |
+
{
|
| 1603 |
+
"datasetId": 1429416,
|
| 1604 |
+
"sourceId": 14451718,
|
| 1605 |
+
"sourceType": "datasetVersion"
|
| 1606 |
+
}
|
| 1607 |
+
],
|
| 1608 |
+
"dockerImageVersionId": 31090,
|
| 1609 |
+
"isGpuEnabled": true,
|
| 1610 |
+
"isInternetEnabled": true,
|
| 1611 |
+
"language": "python",
|
| 1612 |
+
"sourceType": "notebook"
|
| 1613 |
+
},
|
| 1614 |
+
"kernelspec": {
|
| 1615 |
+
"display_name": "Python 3",
|
| 1616 |
+
"name": "python3"
|
| 1617 |
+
},
|
| 1618 |
+
"language_info": {
|
| 1619 |
+
"codemirror_mode": {
|
| 1620 |
+
"name": "ipython",
|
| 1621 |
+
"version": 3
|
| 1622 |
+
},
|
| 1623 |
+
"file_extension": ".py",
|
| 1624 |
+
"mimetype": "text/x-python",
|
| 1625 |
+
"name": "python",
|
| 1626 |
+
"nbconvert_exporter": "python",
|
| 1627 |
+
"pygments_lexer": "ipython3",
|
| 1628 |
+
"version": "3.11.13"
|
| 1629 |
+
},
|
| 1630 |
+
"papermill": {
|
| 1631 |
+
"default_parameters": {},
|
| 1632 |
+
"duration": 20573.990788,
|
| 1633 |
+
"end_time": "2026-01-11T00:00:22.081506",
|
| 1634 |
+
"environment_variables": {},
|
| 1635 |
+
"exception": null,
|
| 1636 |
+
"input_path": "__notebook__.ipynb",
|
| 1637 |
+
"output_path": "__notebook__.ipynb",
|
| 1638 |
+
"parameters": {},
|
| 1639 |
+
"start_time": "2026-01-10T18:17:28.090718",
|
| 1640 |
+
"version": "2.6.0"
|
| 1641 |
+
},
|
| 1642 |
+
"colab": {
|
| 1643 |
+
"provenance": [],
|
| 1644 |
+
"gpuType": "T4"
|
| 1645 |
+
},
|
| 1646 |
+
"accelerator": "GPU"
|
| 1647 |
+
},
|
| 1648 |
+
"nbformat": 4,
|
| 1649 |
+
"nbformat_minor": 5
|
| 1650 |
+
}
|