{"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":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install -q mediapy\n","metadata":{"trusted":true},"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},"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},"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},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_labels.groupby(\"dataset\")[\"scene\"].nunique()\n","metadata":{"trusted":true},"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},"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},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"stairs\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_stpeters_stpauls\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_sacrecoeur_trevi_tajmahal\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_piazzasanmarco_grandplace\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"pt_brandenburg_british_buckingham\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2024_lizard_pond\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2024_dioscuri_baalshamin\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2023_theather_imc2024_church\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2023_heritage\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"imc2023_haiper\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"fbk_vineyard\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"amy_gardens\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_random_images(\"ETs\")\n","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}