{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":91498,"databundleVersionId":11655853,"sourceType":"competition"},{"sourceId":238248914,"sourceType":"kernelVersion"}],"dockerImageVersionId":31041,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"%cd /kaggle/working\n!git clone --recursive https://github.com/naver/mast3r\n# cd mast3r\n# if you have already cloned mast3r:\n# git submodule update --init --recursive","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# !dpkg -i --force-depends /kaggle/input/colmap-offline-installer/archives/*.deb >/dev/null 2>&1","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!mkdir -p /kaggle/working/mast3r-wheels\n\n# 下载到指定目录，不安装\n!pip download torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 -d /kaggle/working/mast3r-wheels\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!mkdir /kaggle/working/mast3r-bin\n# !pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 --target /kaggle/working/mast3r-bin\n!pip install --no-index --find-links=/kaggle/working/mast3r-wheels torch torchvision torchaudio --target /kaggle/working/mast3r-bin","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:38:48.755623Z","iopub.execute_input":"2025-06-06T22:38:48.756436Z","iopub.status.idle":"2025-06-06T22:40:14.186577Z","shell.execute_reply.started":"2025-06-06T22:38:48.756404Z","shell.execute_reply":"2025-06-06T22:40:14.185521Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import sys\nsys.path.insert(0, \"/kaggle/working/mast3r-bin\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:40:55.612128Z","iopub.execute_input":"2025-06-06T22:40:55.612784Z","iopub.status.idle":"2025-06-06T22:40:55.616818Z","shell.execute_reply.started":"2025-06-06T22:40:55.612753Z","shell.execute_reply":"2025-06-06T22:40:55.616135Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 分别下载三个 requirements 的依赖项\n!pip download -r /kaggle/working/mast3r/requirements.txt -d /kaggle/working/mast3r-wheels\n!pip download -r /kaggle/working/mast3r/dust3r/requirements.txt -d /kaggle/working/mast3r-wheels\n!pip download -r /kaggle/working/mast3r/dust3r/requirements_optional.txt -d /kaggle/working/mast3r-wheels","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:41:05.169065Z","iopub.execute_input":"2025-06-06T22:41:05.169311Z","iopub.status.idle":"2025-06-06T22:43:06.749009Z","shell.execute_reply.started":"2025-06-06T22:41:05.169291Z","shell.execute_reply":"2025-06-06T22:43:06.747747Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 离线安装所有依赖（不联网）\n!pip install --no-index --find-links=/kaggle/working/mast3r-wheels \\\n    -r /kaggle/working/mast3r/requirements.txt \\\n    -r /kaggle/working/mast3r/dust3r/requirements.txt \\\n    -r /kaggle/working/mast3r/dust3r/requirements_optional.txt \\\n    --target /kaggle/working/mast3r-bin","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:43:32.359011Z","iopub.execute_input":"2025-06-06T22:43:32.359822Z","iopub.status.idle":"2025-06-06T22:45:38.730945Z","shell.execute_reply.started":"2025-06-06T22:43:32.359788Z","shell.execute_reply":"2025-06-06T22:45:38.729979Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip download faiss-gpu-cu12 -d /kaggle/working/mast3r-wheels\n!pip install faiss-gpu-cu12 --no-index --find-links=/kaggle/working/mast3r-wheels --target /kaggle/working/mast3r-bin\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:46:57.103841Z","iopub.execute_input":"2025-06-06T22:46:57.104456Z","iopub.status.idle":"2025-06-06T22:47:15.572725Z","shell.execute_reply.started":"2025-06-06T22:46:57.104422Z","shell.execute_reply":"2025-06-06T22:47:15.572008Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip download cython -d /kaggle/working/mast3r-wheels\n!pip install cython  --no-index --find-links=/kaggle/working/mast3r-wheels --target /kaggle/working/mast3r-bin","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:47:20.867442Z","iopub.execute_input":"2025-06-06T22:47:20.868177Z","iopub.status.idle":"2025-06-06T22:47:26.221337Z","shell.execute_reply.started":"2025-06-06T22:47:20.868145Z","shell.execute_reply":"2025-06-06T22:47:26.220527Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 1. 确保在 /kaggle/working 目录下\n%cd /kaggle/working/mast3r\n\n# 2. 更新包列表并安装 build-essential (虽然您已经有了，但安全起见)\n!apt-get update -qq\n!apt-get install -y build-essential\n\n# 3. 重新克隆 asmk (以防万一，如果确定目录干净可以跳过)\n!rm -rf asmk\n!git clone https://github.com/jenicek/asmk\n\n# 4. 进入 asmk 的 cython 目录并 Cythonize\n%cd asmk/cython/\n!cythonize *.pyx\n\n# 5. 返回 asmk 根目录\n%cd ..\n\n# 6. 再次尝试安装 asmk 包\n!PYTHONPATH=\"/kaggle/working/mast3r-bin:$PYTHONPATH\" python3 setup.py build_ext --inplace\n\n# 7. 返回 /kaggle/working 目录 (可选)\n%cd ..\n\n# print(\"asmk installed successfully, hopefully!\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T23:00:38.504851Z","iopub.execute_input":"2025-06-06T23:00:38.505137Z","iopub.status.idle":"2025-06-06T23:00:51.650723Z","shell.execute_reply.started":"2025-06-06T23:00:38.505113Z","shell.execute_reply":"2025-06-06T23:00:51.649835Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!find /kaggle/working/mast3r -type f -name \"*.so\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:48:09.407976Z","iopub.execute_input":"2025-06-06T22:48:09.408616Z","iopub.status.idle":"2025-06-06T22:48:09.529235Z","shell.execute_reply.started":"2025-06-06T22:48:09.408589Z","shell.execute_reply":"2025-06-06T22:48:09.528597Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# DUST3R relies on RoPE positional embeddings for which you can compile some cuda kernels for faster runtime.\n%cd /kaggle/working/mast3r/dust3r/croco/models/curope/\n!PYTHONPATH=/kaggle/working/mast3r-bin:$PYTHONPATH python setup.py build_ext --inplace\n%cd ../../../../","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:52:54.936422Z","iopub.execute_input":"2025-06-06T22:52:54.936715Z","iopub.status.idle":"2025-06-06T22:56:03.027243Z","shell.execute_reply.started":"2025-06-06T22:52:54.936659Z","shell.execute_reply":"2025-06-06T22:56:03.026501Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/mast3r\n!mkdir -p checkpoints/\n!wget https://download.europe.naverlabs.com/ComputerVision/MASt3R/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric.pth -P checkpoints/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:56:34.163071Z","iopub.execute_input":"2025-06-06T22:56:34.163332Z","iopub.status.idle":"2025-06-06T22:58:48.458219Z","shell.execute_reply.started":"2025-06-06T22:56:34.163311Z","shell.execute_reply":"2025-06-06T22:58:48.457532Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/mast3r\n!wget https://download.europe.naverlabs.com/ComputerVision/MASt3R/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric_retrieval_trainingfree.pth -P checkpoints/\n!wget https://download.europe.naverlabs.com/ComputerVision/MASt3R/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric_retrieval_codebook.pkl -P checkpoints/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:58:48.459556Z","iopub.execute_input":"2025-06-06T22:58:48.459793Z","iopub.status.idle":"2025-06-06T22:58:58.079411Z","shell.execute_reply.started":"2025-06-06T22:58:48.459771Z","shell.execute_reply":"2025-06-06T22:58:58.078723Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# * Test The MAST3R with the following lines\nget url from: Running on public URL ***\n\n> %cd /kaggle/working/mast3r \\\n> !PYTHONPATH=\"/kaggle/working/mast3r-bin:/kaggle/working/mast3r/asmk:$PYTHONPATH\" python3 demo.py --model_name \\ MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric --share\n","metadata":{}},{"cell_type":"code","source":"# %cd /kaggle/working/mast3r\n# !PYTHONPATH=\"/kaggle/working/mast3r-bin:/kaggle/working/mast3r/asmk:$PYTHONPATH\" python3 demo.py --model_name MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric --share\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T23:01:19.950612Z","iopub.execute_input":"2025-06-06T23:01:19.951236Z","iopub.status.idle":"2025-06-06T23:01:27.463772Z","shell.execute_reply.started":"2025-06-06T23:01:19.951209Z","shell.execute_reply":"2025-06-06T23:01:27.463046Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%ls /kaggle/working/mast3r/checkpoints","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-06T22:59:15.617492Z","iopub.execute_input":"2025-06-06T22:59:15.617779Z","iopub.status.idle":"2025-06-06T22:59:15.738405Z","shell.execute_reply.started":"2025-06-06T22:59:15.617754Z","shell.execute_reply":"2025-06-06T22:59:15.737552Z"}},"outputs":[],"execution_count":null}]}