{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","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"}],"dockerImageVersionId":30919,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install -q mediapy\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:51:32.329954Z","iopub.execute_input":"2025-04-02T13:51:32.330301Z","iopub.status.idle":"2025-04-02T13:51:35.981594Z","shell.execute_reply.started":"2025-04-02T13:51:32.330268Z","shell.execute_reply":"2025-04-02T13:51:35.980386Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/\n!rm -rf /kaggle/working/Hierarchical-Localization\n!git clone --quiet --recursive https://github.com/cvg/Hierarchical-Localization/\n%cd /kaggle/working/Hierarchical-Localization\n!pip install -e .\n\nfrom hloc import extract_features, match_features, reconstruction, visualization, pairs_from_exhaustive\nfrom hloc.visualization import plot_images, read_image\nfrom hloc.utils import viz_3d\n\n%cd /kaggle/working/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:51:40.469968Z","iopub.execute_input":"2025-04-02T13:51:40.470364Z","iopub.status.idle":"2025-04-02T13:52:01.230155Z","shell.execute_reply.started":"2025-04-02T13:51:40.470327Z","shell.execute_reply":"2025-04-02T13:52:01.228940Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from pathlib import Path\n\nimport cv2\nimport mediapy\nimport pandas as pd\nimport plotly.express as px\nimport pycolmap\nimport os\nimport random\nfrom PIL import Image\nimport matplotlib.pyplot as plt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:15.755518Z","iopub.execute_input":"2025-04-02T13:52:15.755931Z","iopub.status.idle":"2025-04-02T13:52:15.760870Z","shell.execute_reply.started":"2025-04-02T13:52:15.755891Z","shell.execute_reply":"2025-04-02T13:52:15.759816Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_labels = pd.read_csv(\"/kaggle/input/image-matching-challenge-2025/train_labels.csv\")\ntrain_labels","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:20.448702Z","iopub.execute_input":"2025-04-02T13:52:20.449059Z","iopub.status.idle":"2025-04-02T13:52:20.474562Z","shell.execute_reply.started":"2025-04-02T13:52:20.449027Z","shell.execute_reply":"2025-04-02T13:52:20.473526Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_labels.groupby(\"dataset\")[\"scene\"].nunique()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:24.881962Z","iopub.execute_input":"2025-04-02T13:52:24.882406Z","iopub.status.idle":"2025-04-02T13:52:24.891629Z","shell.execute_reply.started":"2025-04-02T13:52:24.882358Z","shell.execute_reply":"2025-04-02T13:52:24.890696Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dataset_counts = train_labels[\"dataset\"].value_counts()\n\nplt.figure(figsize=(12, 7))\ndataset_counts.plot(kind='bar', color='skyblue', edgecolor='black')\nplt.title('Distribution of Images Across Datasets', fontsize=16, fontweight='bold')\nplt.xlabel('Dataset', fontsize=14)\nplt.ylabel('Number of Images', fontsize=14)\nplt.xticks(rotation=60, ha='right', fontsize=12)  \nplt.yticks(fontsize=12)\nplt.grid(axis='y', linestyle='--', alpha=0.7)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:29.340679Z","iopub.execute_input":"2025-04-02T13:52:29.341038Z","iopub.status.idle":"2025-04-02T13:52:29.643064Z","shell.execute_reply.started":"2025-04-02T13:52:29.341003Z","shell.execute_reply":"2025-04-02T13:52:29.641988Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def plot_random_images(scene_name, base_path=\"/kaggle/input/image-matching-challenge-2025/train\"):\n    scene_path = os.path.join(base_path, scene_name)\n    image_filenames = [f for f in os.listdir(scene_path) if f.endswith(('.png', '.jpg', '.jpeg'))]\n    random_images = random.sample(image_filenames, min(5, len(image_filenames)))\n    fig, axes = plt.subplots(1, len(random_images), figsize=(15, 5))\n    if len(random_images) == 1:\n        axes = [axes]\n\n    for ax, img_filename in zip(axes, random_images):\n        img_path = os.path.join(scene_path, img_filename)\n        img = Image.open(img_path)\n        ax.imshow(img)\n        ax.set_title(img_filename, fontsize=10)\n        ax.axis('off')\n    plt.tight_layout()\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:35.927846Z","iopub.execute_input":"2025-04-02T13:52:35.928164Z","iopub.status.idle":"2025-04-02T13:52:35.934402Z","shell.execute_reply.started":"2025-04-02T13:52:35.928140Z","shell.execute_reply":"2025-04-02T13:52:35.933390Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"stairs\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:42.019890Z","iopub.execute_input":"2025-04-02T13:52:42.020299Z","iopub.status.idle":"2025-04-02T13:52:43.658475Z","shell.execute_reply.started":"2025-04-02T13:52:42.020266Z","shell.execute_reply":"2025-04-02T13:52:43.657117Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_stpeters_stpauls\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:52.095836Z","iopub.execute_input":"2025-04-02T13:52:52.096150Z","iopub.status.idle":"2025-04-02T13:52:53.380469Z","shell.execute_reply.started":"2025-04-02T13:52:52.096125Z","shell.execute_reply":"2025-04-02T13:52:53.379538Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_sacrecoeur_trevi_tajmahal\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:52:59.884110Z","iopub.execute_input":"2025-04-02T13:52:59.884510Z","iopub.status.idle":"2025-04-02T13:53:01.028379Z","shell.execute_reply.started":"2025-04-02T13:52:59.884477Z","shell.execute_reply":"2025-04-02T13:53:01.027113Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_piazzasanmarco_grandplace\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:04.471742Z","iopub.execute_input":"2025-04-02T13:53:04.472099Z","iopub.status.idle":"2025-04-02T13:53:05.541880Z","shell.execute_reply.started":"2025-04-02T13:53:04.472071Z","shell.execute_reply":"2025-04-02T13:53:05.540476Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_brandenburg_british_buckingham\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:08.655595Z","iopub.execute_input":"2025-04-02T13:53:08.655948Z","iopub.status.idle":"2025-04-02T13:53:10.003469Z","shell.execute_reply.started":"2025-04-02T13:53:08.655909Z","shell.execute_reply":"2025-04-02T13:53:10.002103Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2024_lizard_pond\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:12.516579Z","iopub.execute_input":"2025-04-02T13:53:12.516900Z","iopub.status.idle":"2025-04-02T13:53:13.681222Z","shell.execute_reply.started":"2025-04-02T13:53:12.516876Z","shell.execute_reply":"2025-04-02T13:53:13.679726Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2024_dioscuri_baalshamin\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:16.779934Z","iopub.execute_input":"2025-04-02T13:53:16.780319Z","iopub.status.idle":"2025-04-02T13:53:17.821100Z","shell.execute_reply.started":"2025-04-02T13:53:16.780287Z","shell.execute_reply":"2025-04-02T13:53:17.819749Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2023_theather_imc2024_church\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:28.564809Z","iopub.execute_input":"2025-04-02T13:53:28.565121Z","iopub.status.idle":"2025-04-02T13:53:29.865048Z","shell.execute_reply.started":"2025-04-02T13:53:28.565098Z","shell.execute_reply":"2025-04-02T13:53:29.863468Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2023_heritage\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:32.458377Z","iopub.execute_input":"2025-04-02T13:53:32.458695Z","iopub.status.idle":"2025-04-02T13:53:36.880999Z","shell.execute_reply.started":"2025-04-02T13:53:32.458670Z","shell.execute_reply":"2025-04-02T13:53:36.879542Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2023_haiper\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:40.006026Z","iopub.execute_input":"2025-04-02T13:53:40.006391Z","iopub.status.idle":"2025-04-02T13:53:42.762281Z","shell.execute_reply.started":"2025-04-02T13:53:40.006361Z","shell.execute_reply":"2025-04-02T13:53:42.760696Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"fbk_vineyard\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:46.120445Z","iopub.execute_input":"2025-04-02T13:53:46.120777Z","iopub.status.idle":"2025-04-02T13:53:47.070443Z","shell.execute_reply.started":"2025-04-02T13:53:46.120754Z","shell.execute_reply":"2025-04-02T13:53:47.068845Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"amy_gardens\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:52.569045Z","iopub.execute_input":"2025-04-02T13:53:52.569437Z","iopub.status.idle":"2025-04-02T13:53:53.878931Z","shell.execute_reply.started":"2025-04-02T13:53:52.569388Z","shell.execute_reply":"2025-04-02T13:53:53.877836Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"ETs\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-02T13:53:57.698838Z","iopub.execute_input":"2025-04-02T13:53:57.699158Z","iopub.status.idle":"2025-04-02T13:53:58.540077Z","shell.execute_reply.started":"2025-04-02T13:53:57.699134Z","shell.execute_reply":"2025-04-02T13:53:58.538883Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}