stpete2 commited on
Commit
286807a
·
verified ·
1 Parent(s): ef1635f

Delete biplet_dino_mast3r_ps2_gs_colab_08.ipynb

Browse files
biplet_dino_mast3r_ps2_gs_colab_08.ipynb DELETED
@@ -1,1725 +0,0 @@
1
- {
2
- "metadata": {
3
- "kernelspec": {
4
- "display_name": "Python 3",
5
- "name": "python3"
6
- },
7
- "language_info": {
8
- "name": "python",
9
- "version": "3.12.12",
10
- "mimetype": "text/x-python",
11
- "codemirror_mode": {
12
- "name": "ipython",
13
- "version": 3
14
- },
15
- "pygments_lexer": "ipython3",
16
- "nbconvert_exporter": "python",
17
- "file_extension": ".py"
18
- },
19
- "kaggle": {
20
- "accelerator": "none",
21
- "dataSources": [],
22
- "dockerImageVersionId": 31259,
23
- "isInternetEnabled": true,
24
- "language": "python",
25
- "sourceType": "notebook",
26
- "isGpuEnabled": false
27
- },
28
- "colab": {
29
- "provenance": [],
30
- "gpuType": "T4"
31
- },
32
- "accelerator": "GPU"
33
- },
34
- "nbformat_minor": 0,
35
- "nbformat": 4,
36
- "cells": [
37
- {
38
- "cell_type": "code",
39
- "source": [],
40
- "metadata": {
41
- "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
42
- "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
43
- "trusted": true,
44
- "execution": {
45
- "iopub.status.busy": "2026-01-22T11:23:22.240664Z",
46
- "iopub.execute_input": "2026-01-22T11:23:22.240957Z",
47
- "iopub.status.idle": "2026-01-22T11:23:22.246018Z",
48
- "shell.execute_reply.started": "2026-01-22T11:23:22.240936Z",
49
- "shell.execute_reply": "2026-01-22T11:23:22.245074Z"
50
- },
51
- "id": "yhVNR6GETKyA"
52
- },
53
- "outputs": [],
54
- "execution_count": null
55
- },
56
- {
57
- "cell_type": "code",
58
- "source": [
59
- "# =====================================================================\n",
60
- "# biplet_dino_mast3r_ps2_gs_colab_01.ipynb\n",
61
- "# ASMK を DINO に置き換えたバージョン\n",
62
- "# =====================================================================\n",
63
- "\n",
64
- "# =====================================================================\n",
65
- "# CELL 1: Install Dependencies\n",
66
- "# =====================================================================\n",
67
- "!pip install roma einops timm huggingface_hub\n",
68
- "!pip install opencv-python pillow tqdm pyaml cython plyfile\n",
69
- "!pip install pycolmap trimesh\n",
70
- "!pip install transformers==4.40.0 # DINOに必要\n",
71
- "!pip uninstall -y numpy scipy\n",
72
- "!pip install numpy==1.26.4 scipy==1.11.4\n",
73
- "break"
74
- ],
75
- "metadata": {
76
- "trusted": true,
77
- "id": "6C3QGJD8TKyC",
78
- "colab": {
79
- "base_uri": "https://localhost:8080/",
80
- "height": 1000
81
- },
82
- "outputId": "85f3e1b1-29a1-4829-942f-38b53fcb1b89"
83
- },
84
- "outputs": [
85
- {
86
- "output_type": "stream",
87
- "name": "stdout",
88
- "text": [
89
- "Collecting roma\n",
90
- " Downloading roma-1.5.4-py3-none-any.whl.metadata (5.5 kB)\n",
91
- "Requirement already satisfied: einops in /usr/local/lib/python3.12/dist-packages (0.8.1)\n",
92
- "Requirement already satisfied: timm in /usr/local/lib/python3.12/dist-packages (1.0.24)\n",
93
- "Requirement already satisfied: huggingface_hub in /usr/local/lib/python3.12/dist-packages (0.36.0)\n",
94
- "Requirement already satisfied: torch in /usr/local/lib/python3.12/dist-packages (from timm) (2.9.0+cu126)\n",
95
- "Requirement already satisfied: torchvision in /usr/local/lib/python3.12/dist-packages (from timm) (0.24.0+cu126)\n",
96
- "Requirement already satisfied: pyyaml in /usr/local/lib/python3.12/dist-packages (from timm) (6.0.3)\n",
97
- "Requirement already satisfied: safetensors in /usr/local/lib/python3.12/dist-packages (from timm) (0.7.0)\n",
98
- "Requirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (3.20.3)\n",
99
- "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (2025.3.0)\n",
100
- "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (25.0)\n",
101
- "Requirement already satisfied: requests in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (2.32.4)\n",
102
- "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (4.67.1)\n",
103
- "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (4.15.0)\n",
104
- "Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (1.2.0)\n",
105
- "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (3.4.4)\n",
106
- "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (3.11)\n",
107
- "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (2.5.0)\n",
108
- "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (2026.1.4)\n",
109
- "Requirement already satisfied: setuptools in /usr/local/lib/python3.12/dist-packages (from torch->timm) (75.2.0)\n",
110
- "Requirement already satisfied: sympy>=1.13.3 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (1.14.0)\n",
111
- "Requirement already satisfied: networkx>=2.5.1 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (3.6.1)\n",
112
- "Requirement already satisfied: jinja2 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (3.1.6)\n",
113
- "Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.6.77 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (12.6.77)\n",
114
- "Requirement already satisfied: nvidia-cuda-runtime-cu12==12.6.77 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (12.6.77)\n",
115
- "Requirement already satisfied: nvidia-cuda-cupti-cu12==12.6.80 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (12.6.80)\n",
116
- "Requirement already satisfied: nvidia-cudnn-cu12==9.10.2.21 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (9.10.2.21)\n",
117
- "Requirement already satisfied: nvidia-cublas-cu12==12.6.4.1 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (12.6.4.1)\n",
118
- "Requirement already satisfied: nvidia-cufft-cu12==11.3.0.4 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (11.3.0.4)\n",
119
- "Requirement already satisfied: nvidia-curand-cu12==10.3.7.77 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (10.3.7.77)\n",
120
- "Requirement already satisfied: nvidia-cusolver-cu12==11.7.1.2 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (11.7.1.2)\n",
121
- "Requirement already satisfied: nvidia-cusparse-cu12==12.5.4.2 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (12.5.4.2)\n",
122
- "Requirement already satisfied: nvidia-cusparselt-cu12==0.7.1 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (0.7.1)\n",
123
- "Requirement already satisfied: nvidia-nccl-cu12==2.27.5 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (2.27.5)\n",
124
- "Requirement already satisfied: nvidia-nvshmem-cu12==3.3.20 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (3.3.20)\n",
125
- "Requirement already satisfied: nvidia-nvtx-cu12==12.6.77 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (12.6.77)\n",
126
- "Requirement already satisfied: nvidia-nvjitlink-cu12==12.6.85 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (12.6.85)\n",
127
- "Requirement already satisfied: nvidia-cufile-cu12==1.11.1.6 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (1.11.1.6)\n",
128
- "Requirement already satisfied: triton==3.5.0 in /usr/local/lib/python3.12/dist-packages (from torch->timm) (3.5.0)\n",
129
- "Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (from torchvision->timm) (2.0.2)\n",
130
- "Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in /usr/local/lib/python3.12/dist-packages (from torchvision->timm) (11.3.0)\n",
131
- "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.12/dist-packages (from sympy>=1.13.3->torch->timm) (1.3.0)\n",
132
- "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.12/dist-packages (from jinja2->torch->timm) (3.0.3)\n",
133
- "Downloading roma-1.5.4-py3-none-any.whl (25 kB)\n",
134
- "Installing collected packages: roma\n",
135
- "Successfully installed roma-1.5.4\n",
136
- "Requirement already satisfied: opencv-python in /usr/local/lib/python3.12/dist-packages (4.12.0.88)\n",
137
- "Requirement already satisfied: pillow in /usr/local/lib/python3.12/dist-packages (11.3.0)\n",
138
- "Requirement already satisfied: tqdm in /usr/local/lib/python3.12/dist-packages (4.67.1)\n",
139
- "Collecting pyaml\n",
140
- " Downloading pyaml-25.7.0-py3-none-any.whl.metadata (12 kB)\n",
141
- "Requirement already satisfied: cython in /usr/local/lib/python3.12/dist-packages (3.0.12)\n",
142
- "Collecting plyfile\n",
143
- " Downloading plyfile-1.1.3-py3-none-any.whl.metadata (43 kB)\n",
144
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.3/43.3 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
145
- "\u001b[?25hRequirement already satisfied: numpy<2.3.0,>=2 in /usr/local/lib/python3.12/dist-packages (from opencv-python) (2.0.2)\n",
146
- "Requirement already satisfied: PyYAML in /usr/local/lib/python3.12/dist-packages (from pyaml) (6.0.3)\n",
147
- "Downloading pyaml-25.7.0-py3-none-any.whl (26 kB)\n",
148
- "Downloading plyfile-1.1.3-py3-none-any.whl (36 kB)\n",
149
- "Installing collected packages: pyaml, plyfile\n",
150
- "Successfully installed plyfile-1.1.3 pyaml-25.7.0\n",
151
- "Collecting pycolmap\n",
152
- " Downloading pycolmap-3.13.0-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (10 kB)\n",
153
- "Collecting trimesh\n",
154
- " Downloading trimesh-4.11.1-py3-none-any.whl.metadata (13 kB)\n",
155
- "Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (from pycolmap) (2.0.2)\n",
156
- "Downloading pycolmap-3.13.0-cp312-cp312-manylinux_2_28_x86_64.whl (20.3 MB)\n",
157
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m20.3/20.3 MB\u001b[0m \u001b[31m60.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
158
- "\u001b[?25hDownloading trimesh-4.11.1-py3-none-any.whl (740 kB)\n",
159
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m740.4/740.4 kB\u001b[0m \u001b[31m58.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
160
- "\u001b[?25hInstalling collected packages: trimesh, pycolmap\n",
161
- "Successfully installed pycolmap-3.13.0 trimesh-4.11.1\n",
162
- "Collecting transformers==4.40.0\n",
163
- " Downloading transformers-4.40.0-py3-none-any.whl.metadata (137 kB)\n",
164
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m137.6/137.6 kB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
165
- "\u001b[?25hRequirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (3.20.3)\n",
166
- "Requirement already satisfied: huggingface-hub<1.0,>=0.19.3 in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (0.36.0)\n",
167
- "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (2.0.2)\n",
168
- "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (25.0)\n",
169
- "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (6.0.3)\n",
170
- "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (2025.11.3)\n",
171
- "Requirement already satisfied: requests in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (2.32.4)\n",
172
- "Collecting tokenizers<0.20,>=0.19 (from transformers==4.40.0)\n",
173
- " Downloading tokenizers-0.19.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.7 kB)\n",
174
- "Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (0.7.0)\n",
175
- "Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.12/dist-packages (from transformers==4.40.0) (4.67.1)\n",
176
- "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0,>=0.19.3->transformers==4.40.0) (2025.3.0)\n",
177
- "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0,>=0.19.3->transformers==4.40.0) (4.15.0)\n",
178
- "Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<1.0,>=0.19.3->transformers==4.40.0) (1.2.0)\n",
179
- "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests->transformers==4.40.0) (3.4.4)\n",
180
- "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests->transformers==4.40.0) (3.11)\n",
181
- "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests->transformers==4.40.0) (2.5.0)\n",
182
- "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests->transformers==4.40.0) (2026.1.4)\n",
183
- "Downloading transformers-4.40.0-py3-none-any.whl (9.0 MB)\n",
184
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m9.0/9.0 MB\u001b[0m \u001b[31m104.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
185
- "\u001b[?25hDownloading tokenizers-0.19.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)\n",
186
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.6/3.6 MB\u001b[0m \u001b[31m128.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
187
- "\u001b[?25hInstalling collected packages: tokenizers, transformers\n",
188
- " Attempting uninstall: tokenizers\n",
189
- " Found existing installation: tokenizers 0.22.2\n",
190
- " Uninstalling tokenizers-0.22.2:\n",
191
- " Successfully uninstalled tokenizers-0.22.2\n",
192
- " Attempting uninstall: transformers\n",
193
- " Found existing installation: transformers 4.57.6\n",
194
- " Uninstalling transformers-4.57.6:\n",
195
- " Successfully uninstalled transformers-4.57.6\n",
196
- "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
197
- "sentence-transformers 5.2.0 requires transformers<6.0.0,>=4.41.0, but you have transformers 4.40.0 which is incompatible.\u001b[0m\u001b[31m\n",
198
- "\u001b[0mSuccessfully installed tokenizers-0.19.1 transformers-4.40.0\n",
199
- "Found existing installation: numpy 2.0.2\n",
200
- "Uninstalling numpy-2.0.2:\n",
201
- " Successfully uninstalled numpy-2.0.2\n",
202
- "Found existing installation: scipy 1.16.3\n",
203
- "Uninstalling scipy-1.16.3:\n",
204
- " Successfully uninstalled scipy-1.16.3\n",
205
- "Collecting numpy==1.26.4\n",
206
- " Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)\n",
207
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m61.0/61.0 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
208
- "\u001b[?25hCollecting scipy==1.11.4\n",
209
- " Downloading scipy-1.11.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)\n",
210
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.4/60.4 kB\u001b[0m \u001b[31m6.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
211
- "\u001b[?25hDownloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 MB)\n",
212
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.0/18.0 MB\u001b[0m \u001b[31m83.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
213
- "\u001b[?25hDownloading scipy-1.11.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35.8 MB)\n",
214
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m35.8/35.8 MB\u001b[0m \u001b[31m17.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
215
- "\u001b[?25hInstalling collected packages: numpy, scipy\n",
216
- "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
217
- "mapclassify 2.10.0 requires scipy>=1.12, but you have scipy 1.11.4 which is incompatible.\n",
218
- "opencv-python 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= \"3.9\", but you have numpy 1.26.4 which is incompatible.\n",
219
- "tsfresh 0.21.1 requires scipy>=1.14.0; python_version >= \"3.10\", but you have scipy 1.11.4 which is incompatible.\n",
220
- "pytensor 2.36.3 requires numpy>=2.0, but you have numpy 1.26.4 which is incompatible.\n",
221
- "spopt 0.7.0 requires scipy>=1.12.0, but you have scipy 1.11.4 which is incompatible.\n",
222
- "opencv-python-headless 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= \"3.9\", but you have numpy 1.26.4 which is incompatible.\n",
223
- "opencv-contrib-python 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= \"3.9\", but you have numpy 1.26.4 which is incompatible.\n",
224
- "shap 0.50.0 requires numpy>=2, but you have numpy 1.26.4 which is incompatible.\n",
225
- "sentence-transformers 5.2.0 requires transformers<6.0.0,>=4.41.0, but you have transformers 4.40.0 which is incompatible.\n",
226
- "jax 0.7.2 requires numpy>=2.0, but you have numpy 1.26.4 which is incompatible.\n",
227
- "jax 0.7.2 requires scipy>=1.13, but you have scipy 1.11.4 which is incompatible.\n",
228
- "libpysal 4.14.1 requires scipy>=1.12.0, but you have scipy 1.11.4 which is incompatible.\n",
229
- "rasterio 1.5.0 requires numpy>=2, but you have numpy 1.26.4 which is incompatible.\n",
230
- "access 1.1.10.post3 requires scipy>=1.14.1, but you have scipy 1.11.4 which is incompatible.\n",
231
- "tobler 0.13.0 requires numpy>=2.0, but you have numpy 1.26.4 which is incompatible.\n",
232
- "tobler 0.13.0 requires scipy>=1.13, but you have scipy 1.11.4 which is incompatible.\n",
233
- "esda 2.8.1 requires scipy>=1.12, but you have scipy 1.11.4 which is incompatible.\n",
234
- "inequality 1.1.2 requires scipy>=1.12, but you have scipy 1.11.4 which is incompatible.\n",
235
- "giddy 2.3.8 requires scipy>=1.12, but you have scipy 1.11.4 which is incompatible.\n",
236
- "jaxlib 0.7.2 requires numpy>=2.0, but you have numpy 1.26.4 which is incompatible.\n",
237
- "jaxlib 0.7.2 requires scipy>=1.13, but you have scipy 1.11.4 which is incompatible.\u001b[0m\u001b[31m\n",
238
- "\u001b[0mSuccessfully installed numpy-1.26.4 scipy-1.11.4\n"
239
- ]
240
- },
241
- {
242
- "output_type": "display_data",
243
- "data": {
244
- "application/vnd.colab-display-data+json": {
245
- "pip_warning": {
246
- "packages": [
247
- "numpy"
248
- ]
249
- },
250
- "id": "f72420d6cde94fe0a0232dbc7a5bc5cd"
251
- }
252
- },
253
- "metadata": {}
254
- },
255
- {
256
- "output_type": "error",
257
- "ename": "SyntaxError",
258
- "evalue": "'break' outside loop (ipython-input-2150635115.py, line 15)",
259
- "traceback": [
260
- "\u001b[0;36m File \u001b[0;32m\"/tmp/ipython-input-2150635115.py\"\u001b[0;36m, line \u001b[0;32m15\u001b[0m\n\u001b[0;31m break\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m 'break' outside loop\n"
261
- ]
262
- }
263
- ],
264
- "execution_count": 1
265
- },
266
- {
267
- "cell_type": "code",
268
- "source": [],
269
- "metadata": {
270
- "id": "49QM1qVmdm4k"
271
- },
272
- "execution_count": null,
273
- "outputs": []
274
- },
275
- {
276
- "cell_type": "code",
277
- "source": [],
278
- "metadata": {
279
- "id": "bSUbLgHpeeJ4"
280
- },
281
- "execution_count": null,
282
- "outputs": []
283
- },
284
- {
285
- "cell_type": "code",
286
- "source": [],
287
- "metadata": {
288
- "id": "TPcj5qcmedBw"
289
- },
290
- "execution_count": null,
291
- "outputs": []
292
- },
293
- {
294
- "cell_type": "code",
295
- "source": [
296
- "# restart & run after\n",
297
- "# =====================================================================\n",
298
- "# CELL 2: Mount Drive and Verify\n",
299
- "# =====================================================================\n",
300
- "from google.colab import drive\n",
301
- "drive.mount('/content/drive')\n",
302
- "\n",
303
- "import numpy as np\n",
304
- "print(f\"✓ np: {np.__version__} - {np.__file__}\")\n",
305
- "!pip show numpy | grep Version\n",
306
- "\n",
307
- "try:\n",
308
- " import roma\n",
309
- " print(\"✓ roma is installed\")\n",
310
- "except ModuleNotFoundError:\n",
311
- " print(\"⚠️ roma not found, installing...\")\n",
312
- " !pip install roma\n",
313
- " import roma\n",
314
- " print(\"✓ roma installed\")\n",
315
- "\n",
316
- "# =====================================================================\n",
317
- "# CELL 3: Clone Repositories\n",
318
- "# =====================================================================\n",
319
- "import os\n",
320
- "import sys\n",
321
- "\n",
322
- "# MASt3Rをクローン\n",
323
- "if not os.path.exists('/content/mast3r'):\n",
324
- " print(\"Cloning MASt3R repository...\")\n",
325
- " !git clone --recursive https://github.com/naver/mast3r.git /content/mast3r\n",
326
- " print(\"✓ MASt3R cloned\")\n",
327
- "else:\n",
328
- " print(\"✓ MASt3R already exists\")\n",
329
- "\n",
330
- "# DUSt3Rをクローン(MASt3R内に必要)\n",
331
- "if not os.path.exists('/content/mast3r/dust3r'):\n",
332
- " print(\"Cloning DUSt3R repository...\")\n",
333
- " !git clone --recursive https://github.com/naver/dust3r.git /content/mast3r/dust3r\n",
334
- " print(\"✓ DUSt3R cloned\")\n",
335
- "else:\n",
336
- " print(\"✓ DUSt3R already exists\")\n",
337
- "\n",
338
- "# パスを追加\n",
339
- "sys.path.insert(0, '/content/mast3r')\n",
340
- "sys.path.insert(0, '/content/mast3r/dust3r')\n",
341
- "\n",
342
- "# 確認\n",
343
- "try:\n",
344
- " from dust3r.model import AsymmetricCroCo3DStereo\n",
345
- " print(\"✓ dust3r.model imported successfully\")\n",
346
- "except ImportError as e:\n",
347
- " print(f\"✗ Import error: {e}\")\n",
348
- "\n",
349
- "# croco(MASt3Rの依存関係)もクローン\n",
350
- "if not os.path.exists('/content/mast3r/croco'):\n",
351
- " print(\"Cloning CroCo repository...\")\n",
352
- " !git clone --recursive https://github.com/naver/croco.git /content/mast3r/croco\n",
353
- " print(\"✓ CroCo cloned\")\n",
354
- "\n",
355
- "# =====================================================================\n",
356
- "# CELL 4: Clone and Build Gaussian Splatting\n",
357
- "# =====================================================================\n",
358
- "print(\"\\n\" + \"=\"*70)\n",
359
- "print(\"STEP: Clone Gaussian Splatting\")\n",
360
- "print(\"=\"*70)\n",
361
- "WORK_DIR = \"/content/gaussian-splatting\"\n",
362
- "\n",
363
- "import subprocess\n",
364
- "if not os.path.exists(WORK_DIR):\n",
365
- " subprocess.run([\n",
366
- " \"git\", \"clone\", \"--recursive\",\n",
367
- " \"https://github.com/graphdeco-inria/gaussian-splatting.git\",\n",
368
- " WORK_DIR\n",
369
- " ], capture_output=True)\n",
370
- " print(\"✓ Cloned\")\n",
371
- "else:\n",
372
- " print(\"✓ Already exists\")\n",
373
- "\n",
374
- "# インストールが必要なディレクトリ\n",
375
- "submodules = [\n",
376
- " \"/content/gaussian-splatting/submodules/diff-gaussian-rasterization\",\n",
377
- " \"/content/gaussian-splatting/submodules/simple-knn\"\n",
378
- "]\n",
379
- "\n",
380
- "for path in submodules:\n",
381
- " print(f\"Installing {path}...\")\n",
382
- " subprocess.run([\"pip\", \"install\", path], check=True)\n",
383
- "\n",
384
- "print(\"✓ Custom CUDA modules installed.\")\n",
385
- "\n",
386
- "print(f\"✓ np: {np.__version__} - {np.__file__}\")\n",
387
- "!pip show numpy | grep Version\n",
388
- "\n",
389
- "# =====================================================================\n",
390
- "# CELL 5: Import Core Libraries and Configure Memory\n",
391
- "# =====================================================================\n",
392
- "import os\n",
393
- "import sys\n",
394
- "import gc\n",
395
- "import torch\n",
396
- "import numpy as np\n",
397
- "from pathlib import Path\n",
398
- "from tqdm import tqdm\n",
399
- "import torch.nn.functional as F\n",
400
- "import shutil\n",
401
- "from PIL import Image\n",
402
- "from transformers import AutoImageProcessor, AutoModel\n",
403
- "\n",
404
- "# MEMORY MANAGEMENT\n",
405
- "os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True'\n",
406
- "\n",
407
- "def clear_memory():\n",
408
- " \"\"\"メモリクリア関数\"\"\"\n",
409
- " gc.collect()\n",
410
- " if torch.cuda.is_available():\n",
411
- " torch.cuda.empty_cache()\n",
412
- " torch.cuda.synchronize()\n",
413
- "\n",
414
- "def get_memory_info():\n",
415
- " \"\"\"Get current memory usage\"\"\"\n",
416
- " if torch.cuda.is_available():\n",
417
- " allocated = torch.cuda.memory_allocated() / 1024**3\n",
418
- " reserved = torch.cuda.memory_reserved() / 1024**3\n",
419
- " print(f\"GPU Memory - Allocated: {allocated:.2f}GB, Reserved: {reserved:.2f}GB\")\n",
420
- "\n",
421
- " import psutil\n",
422
- " cpu_mem = psutil.virtual_memory().percent\n",
423
- " print(f\"CPU Memory Usage: {cpu_mem:.1f}%\")\n",
424
- "\n",
425
- "# CONFIGURATION\n",
426
- "class Config:\n",
427
- " DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n",
428
- " MAST3R_WEIGHTS = \"naver/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric\"\n",
429
- " DUST3R_WEIGHTS = \"naver/DUSt3R_ViTLarge_BaseDecoder_512_dpt\"\n",
430
- "\n",
431
- " # DINO設定\n",
432
- " DINO_MODEL = \"facebook/dinov2-base\"\n",
433
- " GLOBAL_TOPK = 20 # 各画像がペアを組む上位K個\n",
434
- "\n",
435
- " IMAGE_SIZE = 224\n",
436
- "\n",
437
- "# =====================================================================\n",
438
- "# CELL 6: Image Preprocessing Functions (Biplet)\n",
439
- "# =====================================================================\n",
440
- "def normalize_image_sizes_biplet(input_dir, output_dir=None, size=1024):\n",
441
- " \"\"\"\n",
442
- " Generates two square crops (Left & Right or Top & Bottom)\n",
443
- " from each image in a directory.\n",
444
- " \"\"\"\n",
445
- " if output_dir is None:\n",
446
- " output_dir = input_dir + \"_biplet\"\n",
447
- "\n",
448
- " os.makedirs(output_dir, exist_ok=True)\n",
449
- "\n",
450
- " print(f\"\\n=== Generating Biplet Crops ({size}x{size}) ===\")\n",
451
- "\n",
452
- " converted_count = 0\n",
453
- " size_stats = {}\n",
454
- "\n",
455
- " for img_file in tqdm(sorted(os.listdir(input_dir)), desc=\"Creating biplets\"):\n",
456
- " if not img_file.lower().endswith(('.jpg', '.jpeg', '.png')):\n",
457
- " continue\n",
458
- "\n",
459
- " input_path = os.path.join(input_dir, img_file)\n",
460
- "\n",
461
- " try:\n",
462
- " img = Image.open(input_path)\n",
463
- " original_size = img.size\n",
464
- "\n",
465
- " size_key = f\"{original_size[0]}x{original_size[1]}\"\n",
466
- " size_stats[size_key] = size_stats.get(size_key, 0) + 1\n",
467
- "\n",
468
- " # Generate 2 crops\n",
469
- " crops = generate_two_crops(img, size)\n",
470
- "\n",
471
- " base_name, ext = os.path.splitext(img_file)\n",
472
- " for mode, cropped_img in crops.items():\n",
473
- " output_path = os.path.join(output_dir, f\"{base_name}_{mode}{ext}\")\n",
474
- " cropped_img.save(output_path, quality=95)\n",
475
- "\n",
476
- " converted_count += 1\n",
477
- "\n",
478
- " except Exception as e:\n",
479
- " print(f\" ✗ Error processing {img_file}: {e}\")\n",
480
- "\n",
481
- " print(f\"\\n✓ Biplet generation complete:\")\n",
482
- " print(f\" Source images: {converted_count}\")\n",
483
- " print(f\" Biplet crops generated: {converted_count * 2}\")\n",
484
- " print(f\" Original size distribution: {size_stats}\")\n",
485
- "\n",
486
- " return output_dir\n",
487
- "\n",
488
- "\n",
489
- "def generate_two_crops(img, size):\n",
490
- " \"\"\"\n",
491
- " Crops the image into a square and returns 2 variations\n",
492
- " \"\"\"\n",
493
- " width, height = img.size\n",
494
- " crop_size = min(width, height)\n",
495
- " crops = {}\n",
496
- "\n",
497
- " if width > height:\n",
498
- " # Landscape → Left & Right\n",
499
- " positions = {\n",
500
- " 'left': 0,\n",
501
- " 'right': width - crop_size\n",
502
- " }\n",
503
- " for mode, x_offset in positions.items():\n",
504
- " box = (x_offset, 0, x_offset + crop_size, crop_size)\n",
505
- " crops[mode] = img.crop(box).resize(\n",
506
- " (size, size),\n",
507
- " Image.Resampling.LANCZOS\n",
508
- " )\n",
509
- " else:\n",
510
- " # Portrait or Square → Top & Bottom\n",
511
- " positions = {\n",
512
- " 'top': 0,\n",
513
- " 'bottom': height - crop_size\n",
514
- " }\n",
515
- " for mode, y_offset in positions.items():\n",
516
- " box = (0, y_offset, crop_size, y_offset + crop_size)\n",
517
- " crops[mode] = img.crop(box).resize(\n",
518
- " (size, size),\n",
519
- " Image.Resampling.LANCZOS\n",
520
- " )\n",
521
- "\n",
522
- " return crops\n",
523
- "\n",
524
- "# =====================================================================\n",
525
- "# CELL 7: Image Loading Function\n",
526
- "# =====================================================================\n",
527
- "def load_images_from_directory(image_dir, max_images=200):\n",
528
- " \"\"\"ディレクトリから画像をロード\"\"\"\n",
529
- " print(f\"\\nLoading images from: {image_dir}\")\n",
530
- "\n",
531
- " valid_extensions = {'.jpg', '.jpeg', '.png', '.bmp'}\n",
532
- " image_paths = []\n",
533
- "\n",
534
- " for ext in valid_extensions:\n",
535
- " image_paths.extend(sorted(Path(image_dir).glob(f'*{ext}')))\n",
536
- " image_paths.extend(sorted(Path(image_dir).glob(f'*{ext.upper()}')))\n",
537
- "\n",
538
- " image_paths = sorted(set(str(p) for p in image_paths))\n",
539
- "\n",
540
- " if len(image_paths) > max_images:\n",
541
- " print(f\"⚠️ Limiting from {len(image_paths)} to {max_images} images\")\n",
542
- " image_paths = image_paths[:max_images]\n",
543
- "\n",
544
- " print(f\"✓ Found {len(image_paths)} images\")\n",
545
- " return image_paths\n",
546
- "\n",
547
- "# =====================================================================\n",
548
- "# CELL 8: MASt3R Model Loading\n",
549
- "# =====================================================================\n",
550
- "def load_mast3r_model(device):\n",
551
- " \"\"\"MASt3Rモデルをロード\"\"\"\n",
552
- " print(\"\\n=== Loading MASt3R Model ===\")\n",
553
- "\n",
554
- " if '/content/mast3r' not in sys.path:\n",
555
- " sys.path.insert(0, '/content/mast3r')\n",
556
- " if '/content/mast3r/dust3r' not in sys.path:\n",
557
- " sys.path.insert(0, '/content/mast3r/dust3r')\n",
558
- "\n",
559
- " from dust3r.model import AsymmetricCroCo3DStereo\n",
560
- "\n",
561
- " try:\n",
562
- " print(f\"Attempting to load: {Config.MAST3R_WEIGHTS}\")\n",
563
- " model = AsymmetricCroCo3DStereo.from_pretrained(Config.MAST3R_WEIGHTS).to(device)\n",
564
- " print(\"✓ Loaded MASt3R model\")\n",
565
- " except Exception as e:\n",
566
- " print(f\"⚠️ Failed to load MASt3R: {e}\")\n",
567
- " print(f\"Trying DUSt3R instead: {Config.DUST3R_WEIGHTS}\")\n",
568
- " model = AsymmetricCroCo3DStereo.from_pretrained(Config.DUST3R_WEIGHTS).to(device)\n",
569
- " print(\"✓ Loaded DUSt3R model as fallback\")\n",
570
- "\n",
571
- " model.eval()\n",
572
- " print(f\"✓ Model loaded on {device}\")\n",
573
- " return model\n",
574
- "\n",
575
- "# =====================================================================\n",
576
- "# CELL 9: DINO Pair Selection (REPLACES ASMK)\n",
577
- "# =====================================================================\n",
578
- "def load_torch_image(fname, device):\n",
579
- " \"\"\"Load image as torch tensor\"\"\"\n",
580
- " import torchvision.transforms as T\n",
581
- "\n",
582
- " img = Image.open(fname).convert('RGB')\n",
583
- " transform = T.Compose([\n",
584
- " T.ToTensor(),\n",
585
- " ])\n",
586
- " return transform(img).unsqueeze(0).to(device)\n",
587
- "\n",
588
- "def extract_dino_global(image_paths, model_path, device):\n",
589
- " \"\"\"Extract DINO global descriptors with memory management\"\"\"\n",
590
- " print(\"\\n=== Extracting DINO Global Features ===\")\n",
591
- " print(\"Initial memory state:\")\n",
592
- " get_memory_info()\n",
593
- "\n",
594
- " processor = AutoImageProcessor.from_pretrained(model_path)\n",
595
- " model = AutoModel.from_pretrained(model_path).eval().to(device)\n",
596
- "\n",
597
- " global_descs = []\n",
598
- " batch_size = 4 # Small batch to save memory\n",
599
- "\n",
600
- " for i in tqdm(range(0, len(image_paths), batch_size), desc=\"DINO extraction\"):\n",
601
- " batch_paths = image_paths[i:i+batch_size]\n",
602
- " batch_imgs = []\n",
603
- "\n",
604
- " for img_path in batch_paths:\n",
605
- " img = load_torch_image(img_path, device)\n",
606
- " batch_imgs.append(img)\n",
607
- "\n",
608
- " batch_tensor = torch.cat(batch_imgs, dim=0)\n",
609
- "\n",
610
- " with torch.no_grad():\n",
611
- " inputs = processor(images=batch_tensor, return_tensors=\"pt\", do_rescale=False).to(device)\n",
612
- " outputs = model(**inputs)\n",
613
- " desc = F.normalize(outputs.last_hidden_state[:, 1:].max(dim=1)[0], dim=1, p=2)\n",
614
- " global_descs.append(desc.cpu())\n",
615
- "\n",
616
- " # Clear batch memory\n",
617
- " del batch_tensor, inputs, outputs, desc\n",
618
- " clear_memory()\n",
619
- "\n",
620
- " global_descs = torch.cat(global_descs, dim=0)\n",
621
- "\n",
622
- " del model, processor\n",
623
- " clear_memory()\n",
624
- "\n",
625
- " print(\"After DINO extraction:\")\n",
626
- " get_memory_info()\n",
627
- "\n",
628
- " return global_descs\n",
629
- "\n",
630
- "def build_topk_pairs(global_feats, k, device):\n",
631
- " \"\"\"Build top-k similar pairs from global features\"\"\"\n",
632
- " g = global_feats.to(device)\n",
633
- " sim = g @ g.T\n",
634
- " sim.fill_diagonal_(-1)\n",
635
- "\n",
636
- " N = sim.size(0)\n",
637
- " k = min(k, N - 1)\n",
638
- "\n",
639
- " topk_indices = torch.topk(sim, k, dim=1).indices.cpu()\n",
640
- "\n",
641
- " pairs = []\n",
642
- " for i in range(N):\n",
643
- " for j in topk_indices[i]:\n",
644
- " j = j.item()\n",
645
- " if i < j:\n",
646
- " pairs.append((i, j))\n",
647
- "\n",
648
- " # Remove duplicates\n",
649
- " pairs = list(set(pairs))\n",
650
- "\n",
651
- " return pairs\n",
652
- "\n",
653
- "def select_diverse_pairs(pairs, max_pairs, num_images):\n",
654
- " \"\"\"\n",
655
- " Select diverse pairs to ensure good image coverage\n",
656
- " \"\"\"\n",
657
- " import random\n",
658
- " random.seed(42)\n",
659
- "\n",
660
- " if len(pairs) <= max_pairs:\n",
661
- " return pairs\n",
662
- "\n",
663
- " print(f\"Selecting {max_pairs} diverse pairs from {len(pairs)} candidates...\")\n",
664
- "\n",
665
- " # Count how many times each image appears in pairs\n",
666
- " image_counts = {i: 0 for i in range(num_images)}\n",
667
- " for i, j in pairs:\n",
668
- " image_counts[i] += 1\n",
669
- " image_counts[j] += 1\n",
670
- "\n",
671
- " # Sort pairs by: prefer pairs with less-connected images\n",
672
- " def pair_score(pair):\n",
673
- " i, j = pair\n",
674
- " return image_counts[i] + image_counts[j]\n",
675
- "\n",
676
- " pairs_scored = [(pair, pair_score(pair)) for pair in pairs]\n",
677
- " pairs_scored.sort(key=lambda x: x[1])\n",
678
- "\n",
679
- " # Select pairs greedily to maximize coverage\n",
680
- " selected = []\n",
681
- " selected_images = set()\n",
682
- "\n",
683
- " # Phase 1: Select pairs that add new images\n",
684
- " for pair, score in pairs_scored:\n",
685
- " if len(selected) >= max_pairs:\n",
686
- " break\n",
687
- " i, j = pair\n",
688
- " if i not in selected_images or j not in selected_images:\n",
689
- " selected.append(pair)\n",
690
- " selected_images.add(i)\n",
691
- " selected_images.add(j)\n",
692
- "\n",
693
- " # Phase 2: Fill remaining slots\n",
694
- " if len(selected) < max_pairs:\n",
695
- " remaining = [p for p, s in pairs_scored if p not in selected]\n",
696
- " random.shuffle(remaining)\n",
697
- " selected.extend(remaining[:max_pairs - len(selected)])\n",
698
- "\n",
699
- " print(f\"Selected pairs cover {len(selected_images)} / {num_images} images ({100*len(selected_images)/num_images:.1f}%)\")\n",
700
- "\n",
701
- " return selected\n",
702
- "\n",
703
- "def get_image_pairs_dino(image_paths, max_pairs=None):\n",
704
- " \"\"\"DINO-based pair selection\"\"\"\n",
705
- " device = Config.DEVICE\n",
706
- "\n",
707
- " # DINO global features\n",
708
- " global_feats = extract_dino_global(image_paths, Config.DINO_MODEL, device)\n",
709
- " pairs = build_topk_pairs(global_feats, Config.GLOBAL_TOPK, device)\n",
710
- "\n",
711
- " print(f\"Initial pairs from DINO: {len(pairs)}\")\n",
712
- "\n",
713
- " # Apply intelligent pair selection if limit specified\n",
714
- " if max_pairs and len(pairs) > max_pairs:\n",
715
- " pairs = select_diverse_pairs(pairs, max_pairs, len(image_paths))\n",
716
- "\n",
717
- " return pairs\n",
718
- "\n",
719
- "# =====================================================================\n",
720
- "# CELL 10: MASt3R Reconstruction\n",
721
- "# =====================================================================\n",
722
- "def run_mast3r_pairs(model, image_paths, pairs, device, batch_size=1, max_pairs=None):\n",
723
- " \"\"\"Run MASt3R on selected pairs with memory management\"\"\"\n",
724
- " print(\"\\n=== Running MASt3R Reconstruction ===\")\n",
725
- " print(\"Initial memory state:\")\n",
726
- " get_memory_info()\n",
727
- "\n",
728
- " from dust3r.inference import inference\n",
729
- " from dust3r.cloud_opt import global_aligner, GlobalAlignerMode\n",
730
- " from dust3r.utils.image import load_images\n",
731
- "\n",
732
- " # Limit number of pairs if specified\n",
733
- " if max_pairs and len(pairs) > max_pairs:\n",
734
- " print(f\"Limiting pairs from {len(pairs)} to {max_pairs}\")\n",
735
- " step = max(1, len(pairs) // max_pairs)\n",
736
- " pairs = pairs[::step][:max_pairs]\n",
737
- "\n",
738
- " print(f\"Processing {len(pairs)} pairs...\")\n",
739
- "\n",
740
- " # Load images in smaller size\n",
741
- " print(f\"Loading {len(image_paths)} images at {Config.IMAGE_SIZE}x{Config.IMAGE_SIZE}...\")\n",
742
- " images = load_images(image_paths, size=Config.IMAGE_SIZE)\n",
743
- "\n",
744
- " print(f\"Loaded {len(images)} images\")\n",
745
- " print(\"After loading images:\")\n",
746
- " get_memory_info()\n",
747
- "\n",
748
- " # Create all image pairs\n",
749
- " print(f\"Creating {len(pairs)} image pairs...\")\n",
750
- " mast3r_pairs = []\n",
751
- " for idx1, idx2 in tqdm(pairs, desc=\"Preparing pairs\"):\n",
752
- " mast3r_pairs.append((images[idx1], images[idx2]))\n",
753
- "\n",
754
- " print(f\"Running MASt3R inference on {len(mast3r_pairs)} pairs...\")\n",
755
- "\n",
756
- " # Run inference\n",
757
- " output = inference(mast3r_pairs, model, device, batch_size=batch_size, verbose=True)\n",
758
- "\n",
759
- " del mast3r_pairs\n",
760
- " clear_memory()\n",
761
- "\n",
762
- " print(\"✓ MASt3R inference complete\")\n",
763
- " print(\"After inference:\")\n",
764
- " get_memory_info()\n",
765
- "\n",
766
- " # Global alignment\n",
767
- " print(\"Running global alignment...\")\n",
768
- " scene = global_aligner(\n",
769
- " output,\n",
770
- " device=device,\n",
771
- " mode=GlobalAlignerMode.PointCloudOptimizer\n",
772
- " )\n",
773
- "\n",
774
- " del output\n",
775
- " clear_memory()\n",
776
- "\n",
777
- " print(\"Computing global alignment...\")\n",
778
- " loss = scene.compute_global_alignment(\n",
779
- " init=\"mst\",\n",
780
- " niter=50, # Reduced iterations\n",
781
- " schedule='cosine',\n",
782
- " lr=0.01\n",
783
- " )\n",
784
- "\n",
785
- " print(f\"✓ Global alignment complete (final loss: {loss:.6f})\")\n",
786
- " print(\"Final memory state:\")\n",
787
- " get_memory_info()\n",
788
- "\n",
789
- " return scene, images\n",
790
- "\n",
791
- "\n",
792
- "\n"
793
- ],
794
- "metadata": {
795
- "trusted": true,
796
- "id": "OWJEB1oQTKyD",
797
- "colab": {
798
- "base_uri": "https://localhost:8080/"
799
- },
800
- "outputId": "c3207607-7af9-4673-d820-d4b44d97d9df"
801
- },
802
- "outputs": [
803
- {
804
- "output_type": "stream",
805
- "name": "stdout",
806
- "text": [
807
- "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n",
808
- "✓ np: 1.26.4 - /usr/local/lib/python3.12/dist-packages/numpy/__init__.py\n",
809
- "Version: 1.26.4\n",
810
- "Version 3.1, 31 March 2009\n",
811
- " Version 3, 29 June 2007\n",
812
- " 5. Conveying Modified Source Versions.\n",
813
- " 14. Revised Versions of this License.\n",
814
- "✓ roma is installed\n",
815
- "✓ MASt3R already exists\n",
816
- "✓ DUSt3R already exists\n",
817
- "✓ dust3r.model imported successfully\n",
818
- "\n",
819
- "======================================================================\n",
820
- "STEP: Clone Gaussian Splatting\n",
821
- "======================================================================\n",
822
- "✓ Already exists\n",
823
- "Installing /content/gaussian-splatting/submodules/diff-gaussian-rasterization...\n",
824
- "Installing /content/gaussian-splatting/submodules/simple-knn...\n",
825
- "✓ Custom CUDA modules installed.\n",
826
- "✓ np: 1.26.4 - /usr/local/lib/python3.12/dist-packages/numpy/__init__.py\n",
827
- "Version: 1.26.4\n",
828
- "Version 3.1, 31 March 2009\n",
829
- " Version 3, 29 June 2007\n",
830
- " 5. Conveying Modified Source Versions.\n",
831
- " 14. Revised Versions of this License.\n"
832
- ]
833
- }
834
- ],
835
- "execution_count": 8
836
- },
837
- {
838
- "cell_type": "code",
839
- "source": [
840
- "\n",
841
- "\n",
842
- "# =====================================================================\n",
843
- "# CELL 11: Camera Parameter Extraction\n",
844
- "# =====================================================================\n",
845
- "def extract_camera_params_process2(scene, image_paths, conf_threshold=1.5):\n",
846
- " \"\"\"sceneからカメラパラメータと3D点を抽出\"\"\"\n",
847
- " print(\"\\n=== Extracting Camera Parameters ===\")\n",
848
- "\n",
849
- " cameras_dict = {}\n",
850
- " all_pts3d = []\n",
851
- " all_confidence = []\n",
852
- "\n",
853
- " try:\n",
854
- " if hasattr(scene, 'get_im_poses'):\n",
855
- " poses = scene.get_im_poses()\n",
856
- " elif hasattr(scene, 'im_poses'):\n",
857
- " poses = scene.im_poses\n",
858
- " else:\n",
859
- " poses = None\n",
860
- "\n",
861
- " if hasattr(scene, 'get_focals'):\n",
862
- " focals = scene.get_focals()\n",
863
- " elif hasattr(scene, 'im_focals'):\n",
864
- " focals = scene.im_focals\n",
865
- " else:\n",
866
- " focals = None\n",
867
- "\n",
868
- " if hasattr(scene, 'get_principal_points'):\n",
869
- " pps = scene.get_principal_points()\n",
870
- " elif hasattr(scene, 'im_pp'):\n",
871
- " pps = scene.im_pp\n",
872
- " else:\n",
873
- " pps = None\n",
874
- " except Exception as e:\n",
875
- " print(f\"⚠️ Error getting camera parameters: {e}\")\n",
876
- " poses = None\n",
877
- " focals = None\n",
878
- " pps = None\n",
879
- "\n",
880
- " n_images = min(len(poses) if poses is not None else len(image_paths), len(image_paths))\n",
881
- "\n",
882
- " for idx in range(n_images):\n",
883
- " img_name = os.path.basename(image_paths[idx])\n",
884
- "\n",
885
- " try:\n",
886
- " # Poseを取得\n",
887
- " if poses is not None and idx < len(poses):\n",
888
- " pose = poses[idx]\n",
889
- " if isinstance(pose, torch.Tensor):\n",
890
- " pose = pose.detach().cpu().numpy()\n",
891
- " if not isinstance(pose, np.ndarray) or pose.shape != (4, 4):\n",
892
- " pose = np.eye(4)\n",
893
- " else:\n",
894
- " pose = np.eye(4)\n",
895
- "\n",
896
- " # Focalを取得\n",
897
- " if focals is not None and idx < len(focals):\n",
898
- " focal = focals[idx]\n",
899
- " if isinstance(focal, torch.Tensor):\n",
900
- " focal = focal.detach().cpu().item()\n",
901
- " else:\n",
902
- " focal = float(focal)\n",
903
- " else:\n",
904
- " focal = 1000.0\n",
905
- "\n",
906
- " # Principal pointを取得\n",
907
- " if pps is not None and idx < len(pps):\n",
908
- " pp = pps[idx]\n",
909
- " if isinstance(pp, torch.Tensor):\n",
910
- " pp = pp.detach().cpu().numpy()\n",
911
- " else:\n",
912
- " pp = np.array([112.0, 112.0])\n",
913
- "\n",
914
- " # カメラパラメータを保存\n",
915
- " cameras_dict[img_name] = {\n",
916
- " 'focal': focal,\n",
917
- " 'pp': pp,\n",
918
- " 'pose': pose,\n",
919
- " 'rotation': pose[:3, :3],\n",
920
- " 'translation': pose[:3, 3],\n",
921
- " 'width': Config.IMAGE_SIZE * 4,\n",
922
- " 'height': Config.IMAGE_SIZE * 4\n",
923
- " }\n",
924
- "\n",
925
- " # 3D点を取得\n",
926
- " if hasattr(scene, 'im_pts3d') and idx < len(scene.im_pts3d):\n",
927
- " pts3d_img = scene.im_pts3d[idx]\n",
928
- " elif hasattr(scene, 'get_pts3d'):\n",
929
- " pts3d_all = scene.get_pts3d()\n",
930
- " if idx < len(pts3d_all):\n",
931
- " pts3d_img = pts3d_all[idx]\n",
932
- " else:\n",
933
- " pts3d_img = None\n",
934
- " else:\n",
935
- " pts3d_img = None\n",
936
- "\n",
937
- " # Confidenceを取得\n",
938
- " if hasattr(scene, 'im_conf') and idx < len(scene.im_conf):\n",
939
- " conf_img = scene.im_conf[idx]\n",
940
- " elif hasattr(scene, 'get_conf'):\n",
941
- " conf_all = scene.get_conf()\n",
942
- " if idx < len(conf_all):\n",
943
- " conf_img = conf_all[idx]\n",
944
- " else:\n",
945
- " conf_img = None\n",
946
- " else:\n",
947
- " conf_img = None\n",
948
- "\n",
949
- " # 3D点とconfidenceを処理\n",
950
- " if pts3d_img is not None:\n",
951
- " if isinstance(pts3d_img, torch.Tensor):\n",
952
- " pts3d_img = pts3d_img.detach().cpu().numpy()\n",
953
- "\n",
954
- " if pts3d_img.ndim == 3:\n",
955
- " pts3d_flat = pts3d_img.reshape(-1, 3)\n",
956
- " else:\n",
957
- " pts3d_flat = pts3d_img\n",
958
- "\n",
959
- " all_pts3d.append(pts3d_flat)\n",
960
- "\n",
961
- " # confidenceを処理\n",
962
- " if conf_img is not None:\n",
963
- " if isinstance(conf_img, list):\n",
964
- " conf_img = np.array(conf_img)\n",
965
- " elif isinstance(conf_img, torch.Tensor):\n",
966
- " conf_img = conf_img.detach().cpu().numpy()\n",
967
- "\n",
968
- " if conf_img.ndim > 1:\n",
969
- " conf_flat = conf_img.reshape(-1)\n",
970
- " else:\n",
971
- " conf_flat = conf_img\n",
972
- "\n",
973
- " if len(conf_flat) != len(pts3d_flat):\n",
974
- " conf_flat = np.ones(len(pts3d_flat))\n",
975
- "\n",
976
- " all_confidence.append(conf_flat)\n",
977
- " else:\n",
978
- " all_confidence.append(np.ones(len(pts3d_flat)))\n",
979
- "\n",
980
- " except Exception as e:\n",
981
- " print(f\"⚠️ Error processing image {idx} ({img_name}): {e}\")\n",
982
- " cameras_dict[img_name] = {\n",
983
- " 'focal': 1000.0,\n",
984
- " 'pp': np.array([112.0, 112.0]),\n",
985
- " 'pose': np.eye(4),\n",
986
- " 'rotation': np.eye(3),\n",
987
- " 'translation': np.zeros(3),\n",
988
- " 'width': Config.IMAGE_SIZE * 4,\n",
989
- " 'height': Config.IMAGE_SIZE * 4\n",
990
- " }\n",
991
- " continue\n",
992
- "\n",
993
- " # 全3D点を結合\n",
994
- " if all_pts3d:\n",
995
- " pts3d = np.vstack(all_pts3d)\n",
996
- " confidence = np.concatenate(all_confidence)\n",
997
- " else:\n",
998
- " pts3d = np.zeros((0, 3))\n",
999
- " confidence = np.zeros(0)\n",
1000
- "\n",
1001
- " print(f\"✓ Extracted camera parameters for {len(cameras_dict)} images\")\n",
1002
- " print(f\"✓ Total 3D points: {len(pts3d)}\")\n",
1003
- "\n",
1004
- " # Confidenceでフィルタリング\n",
1005
- " if len(confidence) > 0:\n",
1006
- " valid_mask = confidence > conf_threshold\n",
1007
- " pts3d = pts3d[valid_mask]\n",
1008
- " confidence = confidence[valid_mask]\n",
1009
- " print(f\"✓ After confidence filtering (>{conf_threshold}): {len(pts3d)} points\")\n",
1010
- "\n",
1011
- " return cameras_dict, pts3d, confidence\n",
1012
- "\n"
1013
- ],
1014
- "metadata": {
1015
- "id": "YSt2RDqmviUa"
1016
- },
1017
- "execution_count": null,
1018
- "outputs": []
1019
- },
1020
- {
1021
- "cell_type": "code",
1022
- "source": [
1023
- "# =====================================================================\n",
1024
- "# CELL 12: COLMAP Export Functions\n",
1025
- "# =====================================================================\n",
1026
- "\n",
1027
- "import struct\n",
1028
- "import pycolmap\n",
1029
- "from pathlib import Path\n",
1030
- "\n",
1031
- "def write_cameras_binary(cameras_dict, image_size, output_file):\n",
1032
- " \"\"\"\n",
1033
- " COLMAPのcameras.binを出力\n",
1034
- "\n",
1035
- " バイナリ形式:\n",
1036
- " - num_cameras (uint64)\n",
1037
- " - For each camera:\n",
1038
- " - camera_id (uint32)\n",
1039
- " - model_id (int32) # SIMPLE_PINHOLE = 0\n",
1040
- " - width (uint64)\n",
1041
- " - height (uint64)\n",
1042
- " - params (double[]) # focal, cx, cy\n",
1043
- "\n",
1044
- " Args:\n",
1045
- " cameras_dict: カメラパラメータの辞書\n",
1046
- " image_size: (width, height) 画像サイズ\n",
1047
- " output_file: 出力ファイルパス\n",
1048
- " \"\"\"\n",
1049
- " width, height = image_size\n",
1050
- " num_cameras = len(cameras_dict)\n",
1051
- "\n",
1052
- " # COLMAP camera models\n",
1053
- " SIMPLE_PINHOLE = 0\n",
1054
- "\n",
1055
- " with open(output_file, 'wb') as f:\n",
1056
- " # カメラ数\n",
1057
- " f.write(struct.pack('Q', num_cameras))\n",
1058
- "\n",
1059
- " # 各カメラの情報\n",
1060
- " for camera_id, (img_id, cam_params) in enumerate(cameras_dict.items(), start=1):\n",
1061
- " focal = cam_params['focal']\n",
1062
- " cx = width / 2.0\n",
1063
- " cy = height / 2.0\n",
1064
- "\n",
1065
- " # camera_id\n",
1066
- " f.write(struct.pack('I', camera_id))\n",
1067
- " # model_id (SIMPLE_PINHOLE)\n",
1068
- " f.write(struct.pack('i', SIMPLE_PINHOLE))\n",
1069
- " # width\n",
1070
- " f.write(struct.pack('Q', width))\n",
1071
- " # height\n",
1072
- " f.write(struct.pack('Q', height))\n",
1073
- " # params: focal, cx, cy\n",
1074
- " f.write(struct.pack('d', focal))\n",
1075
- " f.write(struct.pack('d', cx))\n",
1076
- " f.write(struct.pack('d', cy))\n",
1077
- "\n",
1078
- " print(f\"COLMAP cameras.bin saved to {output_file}\")\n",
1079
- "\n",
1080
- "\n",
1081
- "def write_images_binary(cameras_dict, output_file):\n",
1082
- " \"\"\"\n",
1083
- " COLMAPのimages.binを出力\n",
1084
- "\n",
1085
- " バイナリ形式:\n",
1086
- " - num_images (uint64)\n",
1087
- " - For each image:\n",
1088
- " - image_id (uint32)\n",
1089
- " - qvec (double[4]) # qw, qx, qy, qz\n",
1090
- " - tvec (double[3]) # tx, ty, tz\n",
1091
- " - camera_id (uint32)\n",
1092
- " - name (string with null terminator)\n",
1093
- " - num_points2D (uint64)\n",
1094
- " - points2D (x, y, point3D_id) * num_points2D\n",
1095
- "\n",
1096
- " Args:\n",
1097
- " cameras_dict: カメラパラメータの辞書\n",
1098
- " output_file: 出力ファイルパス\n",
1099
- " \"\"\"\n",
1100
- " num_images = len(cameras_dict)\n",
1101
- "\n",
1102
- " with open(output_file, 'wb') as f:\n",
1103
- " # 画像数\n",
1104
- " f.write(struct.pack('Q', num_images))\n",
1105
- "\n",
1106
- " # 各画像の情報\n",
1107
- " for image_id, (img_id, cam_params) in enumerate(cameras_dict.items(), start=1):\n",
1108
- " # 回転行列をクォータニオンに変換\n",
1109
- " R = cam_params['rotation']\n",
1110
- " quat = pycolmap.rotmat_to_qvec(R) # [qw, qx, qy, qz]\n",
1111
- "\n",
1112
- " # 並進ベクトル\n",
1113
- " t = cam_params['translation']\n",
1114
- "\n",
1115
- " # カメラIDは画像IDと同じ\n",
1116
- " camera_id = image_id\n",
1117
- "\n",
1118
- " # image_id\n",
1119
- " f.write(struct.pack('I', image_id))\n",
1120
- "\n",
1121
- " # qvec (qw, qx, qy, qz)\n",
1122
- " for q in quat:\n",
1123
- " f.write(struct.pack('d', q))\n",
1124
- "\n",
1125
- " # tvec (tx, ty, tz)\n",
1126
- " for ti in t:\n",
1127
- " f.write(struct.pack('d', ti))\n",
1128
- "\n",
1129
- " # camera_id\n",
1130
- " f.write(struct.pack('I', camera_id))\n",
1131
- "\n",
1132
- " # name (null-terminated string)\n",
1133
- " name_bytes = img_id.encode('utf-8') + b'\\x00'\n",
1134
- " f.write(name_bytes)\n",
1135
- "\n",
1136
- " # num_points2D (0 for now)\n",
1137
- " f.write(struct.pack('Q', 0))\n",
1138
- "\n",
1139
- " print(f\"COLMAP images.bin saved to {output_file}\")\n",
1140
- "\n",
1141
- "\n",
1142
- "def write_points3D_binary(pts3d, confidence, output_file):\n",
1143
- " \"\"\"\n",
1144
- " COLMAPのpoints3D.binを出力\n",
1145
- "\n",
1146
- " バイナリ形式:\n",
1147
- " - num_points (uint64)\n",
1148
- " - For each point:\n",
1149
- " - point3D_id (uint64)\n",
1150
- " - xyz (double[3])\n",
1151
- " - rgb (uint8[3])\n",
1152
- " - error (double)\n",
1153
- " - track_length (uint64)\n",
1154
- " - track (image_id, point2D_idx) * track_length\n",
1155
- "\n",
1156
- " Args:\n",
1157
- " pts3d: 3D点の配列 [N, 3]\n",
1158
- " confidence: 信頼度の配列 [N]\n",
1159
- " output_file: 出力ファイルパス\n",
1160
- " \"\"\"\n",
1161
- " num_points = len(pts3d)\n",
1162
- "\n",
1163
- " with open(output_file, 'wb') as f:\n",
1164
- " # 点の数\n",
1165
- " f.write(struct.pack('Q', num_points))\n",
1166
- "\n",
1167
- " # 各3D点の情報\n",
1168
- " for point_id, pt in enumerate(pts3d, start=1):\n",
1169
- " x, y, z = pt\n",
1170
- "\n",
1171
- " # point3D_id\n",
1172
- " f.write(struct.pack('Q', point_id))\n",
1173
- "\n",
1174
- " # xyz\n",
1175
- " f.write(struct.pack('d', x))\n",
1176
- " f.write(struct.pack('d', y))\n",
1177
- " f.write(struct.pack('d', z))\n",
1178
- "\n",
1179
- " # rgb (デフォルトはグレー)\n",
1180
- " f.write(struct.pack('B', 128))\n",
1181
- " f.write(struct.pack('B', 128))\n",
1182
- " f.write(struct.pack('B', 128))\n",
1183
- "\n",
1184
- " # error\n",
1185
- " if confidence is not None and point_id <= len(confidence):\n",
1186
- " error = 1.0 / max(confidence[point_id-1], 0.001)\n",
1187
- " else:\n",
1188
- " error = 1.0\n",
1189
- " f.write(struct.pack('d', error))\n",
1190
- "\n",
1191
- " # track_length (0 for now)\n",
1192
- " f.write(struct.pack('Q', 0))\n",
1193
- "\n",
1194
- " print(f\"COLMAP points3D.bin saved to {output_file}\")\n",
1195
- "\n",
1196
- "\n",
1197
- "def export_colmap_binary(cameras_dict, pts3d, confidence, image_size, output_dir):\n",
1198
- " \"\"\"\n",
1199
- " COLMAPバイナリファイル(cameras.bin, images.bin, points3D.bin)を出力\n",
1200
- "\n",
1201
- " Args:\n",
1202
- " cameras_dict: カメラパラメータの辞書\n",
1203
- " pts3d: 3D点の配列 [N, 3]\n",
1204
- " confidence: 信頼度の配列 [N]\n",
1205
- " image_size: (width, height) 画像サイズ\n",
1206
- " output_dir: 出力ディレクトリパス\n",
1207
- " \"\"\"\n",
1208
- " output_path = Path(output_dir)\n",
1209
- " output_path.mkdir(parents=True, exist_ok=True)\n",
1210
- "\n",
1211
- " # cameras.bin\n",
1212
- " write_cameras_binary(\n",
1213
- " cameras_dict,\n",
1214
- " image_size,\n",
1215
- " output_path / 'cameras.bin'\n",
1216
- " )\n",
1217
- "\n",
1218
- " # images.bin\n",
1219
- " write_images_binary(\n",
1220
- " cameras_dict,\n",
1221
- " output_path / 'images.bin'\n",
1222
- " )\n",
1223
- "\n",
1224
- " # points3D.bin\n",
1225
- " write_points3D_binary(\n",
1226
- " pts3d,\n",
1227
- " confidence,\n",
1228
- " output_path / 'points3D.bin'\n",
1229
- " )\n",
1230
- "\n",
1231
- " print(f\"\\nCOLMAP binary files exported to {output_dir}/\")\n",
1232
- " print(f\" - cameras.bin: {len(cameras_dict)} cameras\")\n",
1233
- " print(f\" - images.bin: {len(cameras_dict)} images\")\n",
1234
- " print(f\" - points3D.bin: {len(pts3d)} points\")"
1235
- ],
1236
- "metadata": {
1237
- "id": "K7Gk6ayZqlJ3"
1238
- },
1239
- "execution_count": 6,
1240
- "outputs": []
1241
- },
1242
- {
1243
- "cell_type": "code",
1244
- "source": [
1245
- "\n",
1246
- "\n",
1247
- "# =====================================================================\n",
1248
- "# CELL 13: Gaussian Splatting Runner\n",
1249
- "# =====================================================================\n",
1250
- "def run_gaussian_splatting(source_dir, output_dir, iterations=30000):\n",
1251
- " \"\"\"Gaussian Splattingを実行\"\"\"\n",
1252
- " print(\"\\n=== Running Gaussian Splatting ===\")\n",
1253
- "\n",
1254
- " os.makedirs(output_dir, exist_ok=True)\n",
1255
- "\n",
1256
- " cmd = [\n",
1257
- " \"python\", \"/content/gaussian-splatting/train.py\",\n",
1258
- " \"-s\", source_dir,\n",
1259
- " \"-m\", output_dir,\n",
1260
- " \"--iterations\", str(iterations),\n",
1261
- " \"--eval\"\n",
1262
- " ]\n",
1263
- "\n",
1264
- " print(f\"Command: {' '.join(cmd)}\")\n",
1265
- " print(f\" Source: {source_dir}\")\n",
1266
- " print(f\" Output: {output_dir}\")\n",
1267
- "\n",
1268
- " result = subprocess.run(cmd, capture_output=False, text=True)\n",
1269
- "\n",
1270
- " if result.returncode == 0:\n",
1271
- " print(f\"\\n✓ Gaussian Splatting complete\")\n",
1272
- "\n",
1273
- " point_cloud_dir = os.path.join(output_dir, \"point_cloud\")\n",
1274
- " if os.path.exists(point_cloud_dir):\n",
1275
- " print(f\"\\n✓ Point cloud directory found: {point_cloud_dir}\")\n",
1276
- "\n",
1277
- " for item in sorted(os.listdir(point_cloud_dir)):\n",
1278
- " item_path = os.path.join(point_cloud_dir, item)\n",
1279
- " if os.path.isdir(item_path) and item.startswith(\"iteration_\"):\n",
1280
- " ply_file = os.path.join(item_path, \"point_cloud.ply\")\n",
1281
- " if os.path.exists(ply_file):\n",
1282
- " file_size = os.path.getsize(ply_file) / (1024 * 1024)\n",
1283
- " print(f\" ✓ {item}/point_cloud.ply ({file_size:.2f} MB)\")\n",
1284
- " else:\n",
1285
- " print(f\"\\n✗ Gaussian Splatting failed with return code {result.returncode}\")\n",
1286
- "\n",
1287
- " return output_dir"
1288
- ],
1289
- "metadata": {
1290
- "id": "o0n2RL3Ep5_Y"
1291
- },
1292
- "execution_count": 4,
1293
- "outputs": []
1294
- },
1295
- {
1296
- "cell_type": "code",
1297
- "source": [
1298
- "# =====================================================================\n",
1299
- "# CELL 14: Main Pipeline\n",
1300
- "# =====================================================================\n",
1301
- "def main_pipeline(image_dir, output_dir, square_size=1024, iterations=30000,\n",
1302
- " max_images=200, max_pairs=100, max_points=500000,\n",
1303
- " conf_threshold=1.001, preprocess_mode='none'):\n",
1304
- " \"\"\"メインパイプライン(DINO + CELL 11/12対応版)\"\"\"\n",
1305
- "\n",
1306
- " # STEP 0: Image Preprocessing\n",
1307
- " if preprocess_mode == 'biplet':\n",
1308
- " print(\"=\"*70)\n",
1309
- " print(\"STEP 0: Image Preprocessing (Biplet Crops)\")\n",
1310
- " print(\"=\"*70)\n",
1311
- "\n",
1312
- " temp_biplet_dir = os.path.join(output_dir, \"temp_biplet\")\n",
1313
- " biplet_dir = normalize_image_sizes_biplet(image_dir, temp_biplet_dir, size=square_size)\n",
1314
- "\n",
1315
- " images_dir = os.path.join(output_dir, \"images\")\n",
1316
- " os.makedirs(images_dir, exist_ok=True)\n",
1317
- "\n",
1318
- " biplet_suffixes = ['_left', '_right', '_top', '_bottom']\n",
1319
- " copied_count = 0\n",
1320
- "\n",
1321
- " for img_file in os.listdir(temp_biplet_dir):\n",
1322
- " if any(suffix in img_file for suffix in biplet_suffixes):\n",
1323
- " src = os.path.join(temp_biplet_dir, img_file)\n",
1324
- " dst = os.path.join(images_dir, img_file)\n",
1325
- " shutil.copy2(src, dst)\n",
1326
- " copied_count += 1\n",
1327
- "\n",
1328
- " print(f\"✓ Copied {copied_count} biplet images to {images_dir}\")\n",
1329
- "\n",
1330
- " original_images_dir = os.path.join(output_dir, \"original_images\")\n",
1331
- " os.makedirs(original_images_dir, exist_ok=True)\n",
1332
- "\n",
1333
- " original_count = 0\n",
1334
- " valid_extensions = ('.jpg', '.jpeg', '.png', '.bmp')\n",
1335
- " for img_file in os.listdir(image_dir):\n",
1336
- " if img_file.lower().endswith(valid_extensions):\n",
1337
- " src = os.path.join(image_dir, img_file)\n",
1338
- " dst = os.path.join(original_images_dir, img_file)\n",
1339
- " shutil.copy2(src, dst)\n",
1340
- " original_count += 1\n",
1341
- "\n",
1342
- " print(f\"✓ Saved {original_count} original images to {original_images_dir}\")\n",
1343
- " shutil.rmtree(temp_biplet_dir)\n",
1344
- " image_dir = images_dir\n",
1345
- " clear_memory()\n",
1346
- " else:\n",
1347
- " images_dir = os.path.join(output_dir, \"images\")\n",
1348
- " if not os.path.exists(images_dir):\n",
1349
- " print(\"=\"*70)\n",
1350
- " print(\"STEP 0: Copying images to output directory\")\n",
1351
- " print(\"=\"*70)\n",
1352
- " shutil.copytree(image_dir, images_dir)\n",
1353
- " print(f\"✓ Copied images to {images_dir}\")\n",
1354
- " image_dir = images_dir\n",
1355
- "\n",
1356
- " # STEP 1: Loading Images\n",
1357
- " print(\"\\n\" + \"=\"*70)\n",
1358
- " print(\"STEP 1: Loading and Preparing Images\")\n",
1359
- " print(\"=\"*70)\n",
1360
- "\n",
1361
- " image_paths = load_images_from_directory(image_dir, max_images=max_images)\n",
1362
- " print(f\"Loaded {len(image_paths)} images\")\n",
1363
- " clear_memory()\n",
1364
- "\n",
1365
- " # STEP 2: Image Pair Selection (DINO)\n",
1366
- " print(\"\\n\" + \"=\"*70)\n",
1367
- " print(\"STEP 2: Image Pair Selection (DINO)\")\n",
1368
- " print(\"=\"*70)\n",
1369
- "\n",
1370
- " max_pairs = min(max_pairs, 50)\n",
1371
- " pairs = get_image_pairs_dino(image_paths, max_pairs=max_pairs)\n",
1372
- " print(f\"Selected {len(pairs)} image pairs\")\n",
1373
- " clear_memory()\n",
1374
- "\n",
1375
- " # STEP 3: MASt3R 3D Reconstruction\n",
1376
- " print(\"\\n\" + \"=\"*70)\n",
1377
- " print(\"STEP 3: MASt3R 3D Reconstruction\")\n",
1378
- " print(\"=\"*70)\n",
1379
- "\n",
1380
- " device = Config.DEVICE\n",
1381
- " model = load_mast3r_model(device)\n",
1382
- " scene, mast3r_images = run_mast3r_pairs(model, image_paths, pairs, device)\n",
1383
- "\n",
1384
- " del model\n",
1385
- " clear_memory()\n",
1386
- "\n",
1387
- "\n",
1388
- "\n",
1389
- " # STEP 4: Converting to COLMAP (CELL 11/12使用)\n",
1390
- " print(\"\\n\" + \"=\"*70)\n",
1391
- " print(\"STEP 4: Converting to COLMAP (PINHOLE)\")\n",
1392
- " print(\"=\"*70)\n",
1393
- "\n",
1394
- " # 画像ファイル名のリストを作成\n",
1395
- " image_names = [os.path.basename(p) for p in image_paths]\n",
1396
- "\n",
1397
- " # CELL 11: カメラパラメータの抽出(修正版関数を使用)\n",
1398
- " cameras_dict, pts3d, confidence = extract_camera_params_process2(\n",
1399
- " scene=scene,\n",
1400
- " image_paths=image_paths,\n",
1401
- " conf_threshold=conf_threshold\n",
1402
- " )\n",
1403
- "\n",
1404
- " print(f\"Extracted {len(cameras_dict)} cameras with conf >= {conf_threshold}\")\n",
1405
- "\n",
1406
- " # 画像サイズを取得(最初の画像から)\n",
1407
- " from PIL import Image\n",
1408
- " first_img = Image.open(image_paths[0])\n",
1409
- " image_size = (first_img.width, first_img.height)\n",
1410
- " first_img.close()\n",
1411
- "\n",
1412
- " # COLMAP出力ディレクトリ\n",
1413
- " colmap_dir = os.path.join(output_dir, \"sparse/0\")\n",
1414
- " os.makedirs(colmap_dir, exist_ok=True)\n",
1415
- "\n",
1416
- " # CELL 12: COLMAPバイナリ形式でエクスポート(修正版関数を使用)\n",
1417
- " export_colmap_binary(\n",
1418
- " cameras_dict=cameras_dict,\n",
1419
- " pts3d=pts3d,\n",
1420
- " confidence=confidence,\n",
1421
- " image_size=image_size,\n",
1422
- " output_dir=colmap_dir\n",
1423
- " )\n",
1424
- "\n",
1425
- " del scene\n",
1426
- " clear_memory()\n",
1427
- "\n",
1428
- "\n",
1429
- "\n",
1430
- " # STEP 5: Running Gaussian Splatting\n",
1431
- " print(\"\\n\" + \"=\"*70)\n",
1432
- " print(\"STEP 5: Running Gaussian Splatting\")\n",
1433
- " print(\"=\"*70)\n",
1434
- "\n",
1435
- " source_dir = output_dir\n",
1436
- " model_output_dir = os.path.join(output_dir, \"gaussian_splatting\")\n",
1437
- "\n",
1438
- " gs_output = run_gaussian_splatting(\n",
1439
- " source_dir=source_dir,\n",
1440
- " output_dir=model_output_dir,\n",
1441
- " iterations=iterations\n",
1442
- " )\n",
1443
- "\n",
1444
- " # STEP 6: Verify Output\n",
1445
- " print(\"\\n\" + \"=\"*70)\n",
1446
- " print(\"PIPELINE COMPLETE\")\n",
1447
- " print(\"=\"*70)\n",
1448
- "\n",
1449
- " ply_path = os.path.join(\n",
1450
- " model_output_dir,\n",
1451
- " \"point_cloud\",\n",
1452
- " f\"iteration_{iterations}\",\n",
1453
- " \"point_cloud.ply\"\n",
1454
- " )\n",
1455
- "\n",
1456
- " if os.path.exists(ply_path):\n",
1457
- " file_size = os.path.getsize(ply_path) / (1024 * 1024)\n",
1458
- " print(f\"✓ Point cloud generated: {ply_path}\")\n",
1459
- " print(f\" Size: {file_size:.2f} MB\")\n",
1460
- " else:\n",
1461
- " print(f\"⚠️ Point cloud not found at: {ply_path}\")\n",
1462
- "\n",
1463
- " print(f\"\\nOutput directory structure:\")\n",
1464
- " print(f\" {output_dir}/\")\n",
1465
- " print(f\" ├── images/ (processed images)\")\n",
1466
- " if preprocess_mode == 'biplet':\n",
1467
- " print(f\" ├── original_images/ (original source images)\")\n",
1468
- " print(f\" ├── sparse/0/ (COLMAP data)\")\n",
1469
- " print(f\" │ ├── cameras.bin\")\n",
1470
- " print(f\" │ ├── images.bin\")\n",
1471
- " print(f\" │ └─�� points3D.bin\")\n",
1472
- " print(f\" └── gaussian_splatting/ (GS output)\")\n",
1473
- "\n",
1474
- " return gs_output"
1475
- ],
1476
- "metadata": {
1477
- "trusted": true,
1478
- "id": "U7Lk41hLTKyF"
1479
- },
1480
- "outputs": [],
1481
- "execution_count": 2
1482
- },
1483
- {
1484
- "cell_type": "code",
1485
- "source": [
1486
- "# =====================================================================\n",
1487
- "# CELL 15: Run Pipeline\n",
1488
- "# =====================================================================\n",
1489
- "if __name__ == \"__main__\":\n",
1490
- " IMAGE_DIR = \"/content/drive/MyDrive/your_folder/fountain\"\n",
1491
- " OUTPUT_DIR = \"/content/output\"\n",
1492
- "\n",
1493
- "\n",
1494
- " gs_output = main_pipeline(\n",
1495
- " image_dir=IMAGE_DIR,\n",
1496
- " output_dir=OUTPUT_DIR,\n",
1497
- " square_size=512,\n",
1498
- " iterations=1000,\n",
1499
- " max_images=10,\n",
1500
- " max_pairs=100,\n",
1501
- " max_points=100000,\n",
1502
- " conf_threshold=0.5,\n",
1503
- " preprocess_mode='biplet' # or 'none'\n",
1504
- " )\n",
1505
- "\n",
1506
- " print(\"\\n\" + \"=\"*70)\n",
1507
- " print(\"PIPELINE COMPLETE\")\n",
1508
- " print(\"=\"*70)\n",
1509
- " print(f\"Output directory: {gs_output}\")"
1510
- ],
1511
- "metadata": {
1512
- "trusted": true,
1513
- "id": "_-8kDLieTKyG",
1514
- "colab": {
1515
- "base_uri": "https://localhost:8080/",
1516
- "height": 1000
1517
- },
1518
- "outputId": "2f2ec105-838e-4531-d259-58dba74aa0c4"
1519
- },
1520
- "outputs": [
1521
- {
1522
- "output_type": "stream",
1523
- "name": "stdout",
1524
- "text": [
1525
- "======================================================================\n",
1526
- "STEP 0: Image Preprocessing (Biplet Crops)\n",
1527
- "======================================================================\n",
1528
- "\n",
1529
- "=== Generating Biplet Crops (512x512) ===\n"
1530
- ]
1531
- },
1532
- {
1533
- "output_type": "stream",
1534
- "name": "stderr",
1535
- "text": [
1536
- "Creating biplets: 100%|██████████| 30/30 [00:02<00:00, 11.05it/s]\n"
1537
- ]
1538
- },
1539
- {
1540
- "output_type": "stream",
1541
- "name": "stdout",
1542
- "text": [
1543
- "\n",
1544
- "✓ Biplet generation complete:\n",
1545
- " Source images: 30\n",
1546
- " Biplet crops generated: 60\n",
1547
- " Original size distribution: {'1440x1920': 30}\n",
1548
- "✓ Copied 60 biplet images to /content/output/images\n",
1549
- "✓ Saved 30 original images to /content/output/original_images\n",
1550
- "\n",
1551
- "======================================================================\n",
1552
- "STEP 1: Loading and Preparing Images\n",
1553
- "======================================================================\n",
1554
- "\n",
1555
- "Loading images from: /content/output/images\n",
1556
- "⚠️ Limiting from 60 to 10 images\n",
1557
- "✓ Found 10 images\n",
1558
- "Loaded 10 images\n",
1559
- "\n",
1560
- "======================================================================\n",
1561
- "STEP 2: Image Pair Selection (DINO)\n",
1562
- "======================================================================\n",
1563
- "\n",
1564
- "=== Extracting DINO Global Features ===\n",
1565
- "Initial memory state:\n",
1566
- "GPU Memory - Allocated: 0.16GB, Reserved: 0.23GB\n",
1567
- "CPU Memory Usage: 42.9%\n"
1568
- ]
1569
- },
1570
- {
1571
- "output_type": "stream",
1572
- "name": "stderr",
1573
- "text": [
1574
- "/usr/local/lib/python3.12/dist-packages/huggingface_hub/file_download.py:942: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
1575
- " warnings.warn(\n",
1576
- "DINO extraction: 100%|██████████| 3/3 [00:01<00:00, 1.58it/s]\n"
1577
- ]
1578
- },
1579
- {
1580
- "output_type": "stream",
1581
- "name": "stdout",
1582
- "text": [
1583
- "After DINO extraction:\n",
1584
- "GPU Memory - Allocated: 0.17GB, Reserved: 0.25GB\n",
1585
- "CPU Memory Usage: 42.9%\n",
1586
- "Initial pairs from DINO: 45\n",
1587
- "Selected 45 image pairs\n",
1588
- "\n",
1589
- "======================================================================\n",
1590
- "STEP 3: MASt3R 3D Reconstruction\n",
1591
- "======================================================================\n",
1592
- "\n",
1593
- "=== Loading MASt3R Model ===\n",
1594
- "Attempting to load: naver/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric\n",
1595
- "⚠️ Failed to load MASt3R: tried to load naver/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric from huggingface, but failed\n",
1596
- "Trying DUSt3R instead: naver/DUSt3R_ViTLarge_BaseDecoder_512_dpt\n",
1597
- "✓ Loaded DUSt3R model as fallback\n",
1598
- "✓ Model loaded on cuda\n",
1599
- "\n",
1600
- "=== Running MASt3R Reconstruction ===\n",
1601
- "Initial memory state:\n",
1602
- "GPU Memory - Allocated: 2.29GB, Reserved: 2.31GB\n",
1603
- "CPU Memory Usage: 42.7%\n",
1604
- "Processing 45 pairs...\n",
1605
- "Loading 10 images at 224x224...\n",
1606
- ">> Loading a list of 10 images\n",
1607
- " - adding /content/output/images/image_001_bottom.jpeg with resolution 512x512 --> 224x224\n",
1608
- " - adding /content/output/images/image_001_top.jpeg with resolution 512x512 --> 224x224\n",
1609
- " - adding /content/output/images/image_002_bottom.jpeg with resolution 512x512 --> 224x224\n",
1610
- " - adding /content/output/images/image_002_top.jpeg with resolution 512x512 --> 224x224\n",
1611
- " - adding /content/output/images/image_003_bottom.jpeg with resolution 512x512 --> 224x224\n",
1612
- " - adding /content/output/images/image_003_top.jpeg with resolution 512x512 --> 224x224\n",
1613
- " - adding /content/output/images/image_004_bottom.jpeg with resolution 512x512 --> 224x224\n",
1614
- " - adding /content/output/images/image_004_top.jpeg with resolution 512x512 --> 224x224\n",
1615
- " - adding /content/output/images/image_005_bottom.jpeg with resolution 512x512 --> 224x224\n",
1616
- " - adding /content/output/images/image_005_top.jpeg with resolution 512x512 --> 224x224\n",
1617
- " (Found 10 images)\n",
1618
- "Loaded 10 images\n",
1619
- "After loading images:\n",
1620
- "GPU Memory - Allocated: 2.29GB, Reserved: 2.31GB\n",
1621
- "CPU Memory Usage: 42.7%\n",
1622
- "Creating 45 image pairs...\n"
1623
- ]
1624
- },
1625
- {
1626
- "output_type": "stream",
1627
- "name": "stderr",
1628
- "text": [
1629
- "Preparing pairs: 100%|██████████| 45/45 [00:00<00:00, 418500.40it/s]\n"
1630
- ]
1631
- },
1632
- {
1633
- "output_type": "stream",
1634
- "name": "stdout",
1635
- "text": [
1636
- "Running MASt3R inference on 45 pairs...\n",
1637
- ">> Inference with model on 45 image pairs\n"
1638
- ]
1639
- },
1640
- {
1641
- "output_type": "stream",
1642
- "name": "stderr",
1643
- "text": [
1644
- "\r 0%| | 0/45 [00:00<?, ?it/s]/content/mast3r/dust3r/dust3r/inference.py:44: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n",
1645
- " with torch.cuda.amp.autocast(enabled=bool(use_amp)):\n",
1646
- "/content/mast3r/dust3r/dust3r/model.py:206: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n",
1647
- " with torch.cuda.amp.autocast(enabled=False):\n",
1648
- "/content/mast3r/dust3r/dust3r/inference.py:48: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.\n",
1649
- " with torch.cuda.amp.autocast(enabled=False):\n",
1650
- "100%|██████████| 45/45 [00:09<00:00, 4.97it/s]\n"
1651
- ]
1652
- },
1653
- {
1654
- "output_type": "stream",
1655
- "name": "stdout",
1656
- "text": [
1657
- "✓ MASt3R inference complete\n",
1658
- "After inference:\n",
1659
- "GPU Memory - Allocated: 2.29GB, Reserved: 2.31GB\n",
1660
- "CPU Memory Usage: 42.8%\n",
1661
- "Running global alignment...\n",
1662
- "Computing global alignment...\n",
1663
- " init edge (5*,6*) score=24.7253360748291\n",
1664
- " init edge (0*,6) score=23.234012603759766\n",
1665
- " init edge (5,8*) score=23.094316482543945\n",
1666
- " init edge (4*,8) score=17.659948348999023\n",
1667
- " init edge (1*,5) score=17.392501831054688\n",
1668
- " init edge (0,2*) score=24.667621612548828\n",
1669
- " init edge (3*,4) score=18.220979690551758\n",
1670
- " init edge (3,7*) score=19.910110473632812\n",
1671
- " init edge (7,9*) score=16.708948135375977\n",
1672
- " init loss = 0.03214450180530548\n",
1673
- "Global alignement - optimizing for:\n",
1674
- "['pw_poses', 'im_depthmaps', 'im_poses', 'im_focals']\n"
1675
- ]
1676
- },
1677
- {
1678
- "output_type": "stream",
1679
- "name": "stderr",
1680
- "text": [
1681
- "100%|██████████| 50/50 [00:01<00:00, 27.62it/s, lr=1.08654e-05 loss=0.0209993]\n"
1682
- ]
1683
- },
1684
- {
1685
- "output_type": "stream",
1686
- "name": "stdout",
1687
- "text": [
1688
- "✓ Global alignment complete (final loss: 0.020999)\n",
1689
- "Final memory state:\n",
1690
- "GPU Memory - Allocated: 2.43GB, Reserved: 2.72GB\n",
1691
- "CPU Memory Usage: 42.8%\n",
1692
- "\n",
1693
- "======================================================================\n",
1694
- "STEP 4: Converting to COLMAP (PINHOLE)\n",
1695
- "======================================================================\n"
1696
- ]
1697
- },
1698
- {
1699
- "output_type": "error",
1700
- "ename": "TypeError",
1701
- "evalue": "'PointCloudOptimizer' object is not subscriptable",
1702
- "traceback": [
1703
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
1704
- "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
1705
- "\u001b[0;32m/tmp/ipython-input-96148482.py\u001b[0m in \u001b[0;36m<cell line: 0>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m gs_output = main_pipeline(\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0mimage_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mIMAGE_DIR\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0moutput_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mOUTPUT_DIR\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1706
- "\u001b[0;32m/tmp/ipython-input-3055082280.py\u001b[0m in \u001b[0;36mmain_pipeline\u001b[0;34m(image_dir, output_dir, square_size, iterations, max_images, max_pairs, max_points, conf_threshold, preprocess_mode)\u001b[0m\n\u001b[1;32m 97\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[0;31m# CELL 11: カメラパラメータの抽出\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 99\u001b[0;31m cameras_dict = extract_camera_params(\n\u001b[0m\u001b[1;32m 100\u001b[0m \u001b[0mreconstruction\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mscene\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 101\u001b[0m \u001b[0mimage_ids\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mimage_names\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1707
- "\u001b[0;32m/tmp/ipython-input-844579717.py\u001b[0m in \u001b[0;36mextract_camera_params\u001b[0;34m(reconstruction, image_ids, match_conf_th)\u001b[0m\n\u001b[1;32m 678\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 679\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0midx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mimg_id\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimage_ids\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 680\u001b[0;31m \u001b[0mpose\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mreconstruction\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'poses'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0midx\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 681\u001b[0m \u001b[0mR\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpose\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m:\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 682\u001b[0m \u001b[0mt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpose\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1708
- "\u001b[0;31mTypeError\u001b[0m: 'PointCloudOptimizer' object is not subscriptable"
1709
- ]
1710
- }
1711
- ],
1712
- "execution_count": 9
1713
- },
1714
- {
1715
- "cell_type": "code",
1716
- "source": [],
1717
- "metadata": {
1718
- "trusted": true,
1719
- "id": "vVlwllleTKyG"
1720
- },
1721
- "outputs": [],
1722
- "execution_count": null
1723
- }
1724
- ]
1725
- }