{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# <center style=\"font-family: consolas; font-size: 32px; font-weight: bold;\"> 🏛️ Image Matching Challenge - 📊 Exploratory Data Analysis</center>\n<p><center style=\"color:#949494; font-family: consolas; font-size: 20px;\">Reconstruct 3D scenes from 2D images</center></p>\n\n***","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"markdown","source":"# <center style=\"font-family: consolas; font-size: 32px; font-weight: bold;\">(ಠಿ⁠_⁠ಠ) Overview</center>\n\n<p style=\"font-family: consolas; font-size: 16px;\">⚪ The goal of this competition is to reconstruct accurate 3D maps from many different views, mapping the world from assorted and noisy data sources, such as images uploaded by users to services like Google Maps.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">⚪ The work in helping to build accurate 3D models may have applications to photography, cultural heritage preservation, and many services across Google.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">⚪ The process of reconstructing a 3D model of an environment from a collection of images is called Structure from Motion (SfM). Combining photos from different sources can create a more complete, three-dimensional view of any given thing.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">⚪ The competition is hosted by Google in collaboration with Haiper and Kaggle.</p>","metadata":{}},{"cell_type":"markdown","source":"#### <a id=\"top\"></a>\n# <div style=\"box-shadow: rgb(60, 121, 245) 0px 0px 0px 3px inset, rgb(255, 255, 255) 10px -10px 0px -3px, rgb(31, 193, 27) 10px -10px, rgb(255, 255, 255) 20px -20px 0px -3px, rgb(255, 217, 19) 20px -20px, rgb(255, 255, 255) 30px -30px 0px -3px, rgb(255, 156, 85) 30px -30px, rgb(255, 255, 255) 40px -40px 0px -3px, rgb(255, 85, 85) 40px -40px; padding:20px; margin-right: 40px; font-size:30px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(60, 121, 245);\"><b>Table of contents</b></div>\n\n<div style=\"background-color: rgba(60, 121, 245, 0.03); padding:30px; font-size:15px; font-family: consolas;\">\n\n* [0. Import all dependencies](#0)\n* [1. Overview directories](#1)\n* [2. Dataset heritage](#2)\n    * [2.1 Scene dioscuri](#2.1)\n    * [2.2 Scene wall](#2.2)\n    * [2.3 Scene cyprus](#2.3)\n* [3. Dataset haiper](#3)\n    * [3.1 Scene fountain](#3.1)\n    * [3.2 Scene chairs](#3.2)\n    * [3.3 Scene bike](#3.3)\n* [4. Dataset urban](#4)\n    * [4.1 Scene kyiv-puppet-theater](#4.1)\n</div>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"0\"></a>\n# <div style=\"box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px inset, rgb(51, 51, 51) 0px 0px 0px 3px inset; padding:20px; font-size:32px; font-family: consolas; text-align:center; display:fill; border-radius:15px;  color:rgb(34, 34, 34);\"> <b> 0. Install & Import all dependencies </b></div>","metadata":{}},{"cell_type":"code","source":"!pip install mediapy -q","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-04-12T00:19:00.905388Z","iopub.execute_input":"2023-04-12T00:19:00.905998Z","iopub.status.idle":"2023-04-12T00:19:15.684217Z","shell.execute_reply.started":"2023-04-12T00:19:00.905947Z","shell.execute_reply":"2023-04-12T00:19:15.682373Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"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":{"execution":{"iopub.status.busy":"2023-04-12T00:19:15.688806Z","iopub.execute_input":"2023-04-12T00:19:15.689446Z","iopub.status.idle":"2023-04-12T00:19:54.142250Z","shell.execute_reply.started":"2023-04-12T00:19:15.689380Z","shell.execute_reply":"2023-04-12T00:19:54.140600Z"},"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport cv2\nimport pycolmap\n\nimport numpy as np\nimport mediapy as media\nimport pandas as pd\nimport plotly.express as px\nimport plotly.graph_objects as go\n\nfrom glob import glob\nfrom pathlib import Path\nfrom time import time","metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2023-04-12T00:19:54.144201Z","iopub.execute_input":"2023-04-12T00:19:54.145066Z","iopub.status.idle":"2023-04-12T00:19:56.142862Z","shell.execute_reply.started":"2023-04-12T00:19:54.145001Z","shell.execute_reply":"2023-04-12T00:19:56.140866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"1\"></a>\n# <div style=\"box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px inset, rgb(51, 51, 51) 0px 0px 0px 3px inset; padding:20px; font-size:32px; font-family: consolas; text-align:center; display:fill; border-radius:15px;  color:rgb(34, 34, 34);\"> <b> 1. Overview directories</b></div>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">⚪ <code>[train/test]/*[dataset]/*[scene]/images</code> - a batch of images all taken near the same location. Some of training datasets may also contain a folder named images_full with additional images.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">⚪ <code>train/*[dataset]/*[scene]/sfm</code> - a 3D reconstruction for this batch of images, which can be opened with colmap, the 3D structure-from-motion library bundled with this competition.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">⚪ <code>train/*[dataset]/*[scene]/LICENSE.txt</code> - the license for this dataset.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">⚪ <code>train/train_labels.csv</code> - a list of images in these datasets, with ground truth.</p>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">🔴 Let's take a closer look at file <code>train_labels.csv</code>.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">Columns:</p>\n\n* <p style=\"font-family: consolas; font-size: 16px;\"><code>dataset</code>: The unique identifier for the dataset.</p>\n* <p style=\"font-family: consolas; font-size: 16px;\"><code>scene</code>: The unique identifier for the scene.</p>\n* <p style=\"font-family: consolas; font-size: 16px;\"><code>image_path</code>: The image filename, including the path.</p>\n* <p style=\"font-family: consolas; font-size: 16px;\"><code>rotation_matrix</code>: The first target column. A <b>3x3</b> matrix, flattened into a vector in row-major convection, with values separated by <code>;</code>.</p>\n* <p style=\"font-family: consolas; font-size: 16px;\"><code>translation_vector</code>: The second target column. A 3-D dimensional vector, with values separated by <code>;</code>.</p>","metadata":{}},{"cell_type":"code","source":"train_labels_df = pd.read_csv(\"/kaggle/input/image-matching-challenge-2023/train/train_labels.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:19:56.146972Z","iopub.execute_input":"2023-04-12T00:19:56.148379Z","iopub.status.idle":"2023-04-12T00:19:56.177772Z","shell.execute_reply.started":"2023-04-12T00:19:56.148319Z","shell.execute_reply":"2023-04-12T00:19:56.176618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_labels_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:19:56.178948Z","iopub.execute_input":"2023-04-12T00:19:56.179707Z","iopub.status.idle":"2023-04-12T00:19:56.214310Z","shell.execute_reply.started":"2023-04-12T00:19:56.179665Z","shell.execute_reply":"2023-04-12T00:19:56.212857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's output the main characteristics of the file using the <code>describe</code> method.</p>","metadata":{}},{"cell_type":"code","source":"train_labels_df.describe()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:19:56.215884Z","iopub.execute_input":"2023-04-12T00:19:56.216384Z","iopub.status.idle":"2023-04-12T00:19:56.251145Z","shell.execute_reply.started":"2023-04-12T00:19:56.216336Z","shell.execute_reply":"2023-04-12T00:19:56.249483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ As we can see, the parameters <i>dataset</i> and <i>scene</i> match those described earlier as subdirectories in train. Let's take a closer look at each of them.</p>","metadata":{}},{"cell_type":"code","source":"dataset_counts = train_labels_df.dataset.value_counts()\n\nfig = px.pie(values=dataset_counts.values, names=dataset_counts.index)\nfig.update_traces(textposition='inside', textfont_size=14)\nfig.update_layout(\n    title={\n        'text': \"Pie distribution of dataset images\",\n        'y':0.95,\n        'x':0.5,\n        'xanchor': 'center',\n        'yanchor': 'top'\n    },\n    legend_title_text='Dataset names:'\n)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:19:56.252972Z","iopub.execute_input":"2023-04-12T00:19:56.253543Z","iopub.status.idle":"2023-04-12T00:19:58.185409Z","shell.execute_reply.started":"2023-04-12T00:19:56.253453Z","shell.execute_reply":"2023-04-12T00:19:58.183239Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scene_counts = train_labels_df.scene.value_counts()\n\nfig = px.pie(values=scene_counts.values, names=scene_counts.index)\nfig.update_traces(textposition='inside', textfont_size=14)\nfig.update_layout(\n    title={\n        'text': \"Pie distribution of scene images\",\n        'y':0.95,\n        'x':0.5,\n        'xanchor': 'center',\n        'yanchor': 'top'\n    },\n    legend_title_text='Scene names:'\n)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:19:58.187408Z","iopub.execute_input":"2023-04-12T00:19:58.187894Z","iopub.status.idle":"2023-04-12T00:19:58.256765Z","shell.execute_reply.started":"2023-04-12T00:19:58.187854Z","shell.execute_reply":"2023-04-12T00:19:58.255751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Now let's see how <i>dataset</i> and <i>scene</i> relate to each other.</p>","metadata":{}},{"cell_type":"code","source":"fig = px.sunburst(train_labels_df, path=['dataset', 'scene'])\nfig.update_layout(\n    title={\n        'text': \"Dataset and scene relation\",\n        'y':0.95,\n        'x':0.5,\n        'xanchor': 'center',\n        'yanchor': 'top'\n    }\n)\n\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:19:58.258229Z","iopub.execute_input":"2023-04-12T00:19:58.259386Z","iopub.status.idle":"2023-04-12T00:19:58.397782Z","shell.execute_reply.started":"2023-04-12T00:19:58.259345Z","shell.execute_reply":"2023-04-12T00:19:58.396347Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❗ As you can see, most of the training dataset is located in the <code>dataset</code> <i>heritage</i>, and the largest <code>scene</code> is <i>dioscuri</i>.</p>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">⚪ Let's consider each dataset and scene in a separate section.</p>","metadata":{}},{"cell_type":"markdown","source":"<a id=\"2\"></a>\n# <div style=\"box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px inset, rgb(51, 51, 51) 0px 0px 0px 3px inset; padding:20px; font-size:32px; font-family: consolas; text-align:center; display:fill; border-radius:15px;  color:rgb(34, 34, 34);\"> <b> 2. Dataset <i>heritage</i></b></div>","metadata":{}},{"cell_type":"code","source":"dataset = 'heritage'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:19:58.402019Z","iopub.execute_input":"2023-04-12T00:19:58.402438Z","iopub.status.idle":"2023-04-12T00:19:58.410402Z","shell.execute_reply.started":"2023-04-12T00:19:58.402401Z","shell.execute_reply":"2023-04-12T00:19:58.408205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"2.1\"></a>\n## <div style=\"box-shadow: rgba(0, 0, 0, 0.18) 0px 2px 4px inset; padding:20px; font-size:24px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(67, 66, 66)\"> <b> 2.1 Scene <i>dioscuri</i></b></div>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">⚪ The Temple of the Dioscuri, also known as the Temple of Castor and Pollux, is an ancient Roman temple located in the Roman Forum, in Rome, Italy. </p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">The temple was originally built in the 5th century BCE, but it was destroyed by fire in 14 CE and then rebuilt by Emperor Tiberius. The temple was rectangular in shape and featured six columns on the front and back, and eleven columns on the sides. The columns were made of marble and had Corinthian capitals.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">The Temple of the Dioscuri was an important religious and political center in ancient Rome, and it was used for various ceremonies and meetings. The temple's remains can still be seen in the Roman Forum today, and it is a popular tourist attraction.</p>","metadata":{}},{"cell_type":"code","source":"scene = 'dioscuri'\nsrc = f'/kaggle/input/image-matching-challenge-2023/train/{dataset}/{scene}'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:19:58.412414Z","iopub.execute_input":"2023-04-12T00:19:58.412915Z","iopub.status.idle":"2023-04-12T00:19:58.422754Z","shell.execute_reply.started":"2023-04-12T00:19:58.412870Z","shell.execute_reply":"2023-04-12T00:19:58.420868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"limit = 12\nimages = [cv2.cvtColor(cv2.imread(im), cv2.COLOR_BGR2RGB) for im in glob(f'{src}/images/*')[:limit]]\nmedia.show_images(images, height=300, columns=3)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:19:58.424876Z","iopub.execute_input":"2023-04-12T00:19:58.425425Z","iopub.status.idle":"2023-04-12T00:20:00.129957Z","shell.execute_reply.started":"2023-04-12T00:19:58.425371Z","shell.execute_reply":"2023-04-12T00:20:00.127977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's plot a 3D map of the scene.</p>","metadata":{}},{"cell_type":"code","source":"rec_gt = pycolmap.Reconstruction(f'{src}/sfm')\n\nfig = viz_3d.init_figure()\n# viz_3d.plot_cameras(fig, rec_gt, color='rgba(50,255,50, 0.5)', name=\"Ground Truth\", size=10)\nviz_3d.plot_reconstruction(fig, rec_gt, cameras = False, color='rgba(227,168,30,0.5)', name=\"Ground Truth\", cs=5)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:20:00.132141Z","iopub.execute_input":"2023-04-12T00:20:00.134877Z","iopub.status.idle":"2023-04-12T00:20:09.463494Z","shell.execute_reply.started":"2023-04-12T00:20:00.134826Z","shell.execute_reply":"2023-04-12T00:20:09.461189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"2.2\"></a>\n## <div style=\"box-shadow: rgba(0, 0, 0, 0.18) 0px 2px 4px inset; padding:20px; font-size:24px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(67, 66, 66)\"> <b> 2.2 Scene <i>wall</i></b></div>","metadata":{}},{"cell_type":"code","source":"scene = 'wall'\nsrc = f'/kaggle/input/image-matching-challenge-2023/train/{dataset}/{scene}'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:09.465757Z","iopub.execute_input":"2023-04-12T00:20:09.466425Z","iopub.status.idle":"2023-04-12T00:20:09.475822Z","shell.execute_reply.started":"2023-04-12T00:20:09.466353Z","shell.execute_reply":"2023-04-12T00:20:09.473162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"limit = 12\nimages = [cv2.cvtColor(cv2.imread(im), cv2.COLOR_BGR2RGB) for im in glob(f'{src}/images/*')[:limit]]\nmedia.show_images(images, height=300, columns=3)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:09.477329Z","iopub.execute_input":"2023-04-12T00:20:09.477709Z","iopub.status.idle":"2023-04-12T00:20:23.333701Z","shell.execute_reply.started":"2023-04-12T00:20:09.477674Z","shell.execute_reply":"2023-04-12T00:20:23.331777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's plot a 3D map of the scene.</p>","metadata":{}},{"cell_type":"code","source":"rec_gt = pycolmap.Reconstruction(f'{src}/sfm')\n\nfig = viz_3d.init_figure()\n# viz_3d.plot_cameras(fig, rec_gt, color='rgba(50,255,50, 0.5)', name=\"Ground Truth\", size=10)\nviz_3d.plot_reconstruction(fig, rec_gt, cameras = False, color='rgba(107,104,90,0.5)', name=\"Ground Truth\", cs=5)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:20:23.336297Z","iopub.execute_input":"2023-04-12T00:20:23.337402Z","iopub.status.idle":"2023-04-12T00:20:29.785814Z","shell.execute_reply.started":"2023-04-12T00:20:23.337357Z","shell.execute_reply":"2023-04-12T00:20:29.783448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"2.3\"></a>\n## <div style=\"box-shadow: rgba(0, 0, 0, 0.18) 0px 2px 4px inset; padding:20px; font-size:24px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(67, 66, 66)\"> <b> 2.3 Scene <i>cyprus</i></b></div>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">⚪ Saranta Kolones (meaning \"Forty Columns\" in Greek) is a medieval castle located in Paphos, Cyprus. The castle was built in the 7th century by the Byzantines as a military fortification, and it was later destroyed by an earthquake in the 13th century.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">The castle is so named because of the numerous granite columns that still stand on the site, despite the destruction caused by the earthquake. These columns are believed to have once supported the castle's roof and upper floors.</p>","metadata":{}},{"cell_type":"code","source":"scene = 'cyprus'\nsrc = f'/kaggle/input/image-matching-challenge-2023/train/{dataset}/{scene}'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:29.787757Z","iopub.execute_input":"2023-04-12T00:20:29.789278Z","iopub.status.idle":"2023-04-12T00:20:29.795157Z","shell.execute_reply.started":"2023-04-12T00:20:29.789225Z","shell.execute_reply":"2023-04-12T00:20:29.793446Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"limit = 12\nimages = [cv2.cvtColor(cv2.imread(im), cv2.COLOR_BGR2RGB) for im in glob(f'{src}/images/*')[:limit]]\nmedia.show_images(images, height=300, columns=3)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:29.797204Z","iopub.execute_input":"2023-04-12T00:20:29.797955Z","iopub.status.idle":"2023-04-12T00:20:42.714460Z","shell.execute_reply.started":"2023-04-12T00:20:29.797908Z","shell.execute_reply":"2023-04-12T00:20:42.712366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's plot a 3D map of the scene.</p>","metadata":{}},{"cell_type":"code","source":"rec_gt = pycolmap.Reconstruction(f'{src}/sfm')\n\nfig = viz_3d.init_figure()\n# viz_3d.plot_cameras(fig, rec_gt, color='rgba(50,255,50, 0.5)', name=\"Ground Truth\", size=10)\nviz_3d.plot_reconstruction(fig, rec_gt, cameras = False, color='rgba(245,212,66,0.5)', name=\"Ground Truth\", cs=5)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:20:42.716176Z","iopub.execute_input":"2023-04-12T00:20:42.717239Z","iopub.status.idle":"2023-04-12T00:20:47.413646Z","shell.execute_reply.started":"2023-04-12T00:20:42.717191Z","shell.execute_reply":"2023-04-12T00:20:47.410879Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"3\"></a>\n# <div style=\"box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px inset, rgb(51, 51, 51) 0px 0px 0px 3px inset; padding:20px; font-size:32px; font-family: consolas; text-align:center; display:fill; border-radius:15px;  color:rgb(34, 34, 34);\"> <b> 3. Dataset <i>haiper</i></b></div>","metadata":{}},{"cell_type":"code","source":"dataset = 'haiper'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:47.415354Z","iopub.execute_input":"2023-04-12T00:20:47.415781Z","iopub.status.idle":"2023-04-12T00:20:47.423071Z","shell.execute_reply.started":"2023-04-12T00:20:47.415744Z","shell.execute_reply":"2023-04-12T00:20:47.421186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"3.1\"></a>\n## <div style=\"box-shadow: rgba(0, 0, 0, 0.18) 0px 2px 4px inset; padding:20px; font-size:24px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(67, 66, 66)\"> <b> 3.1 Scene <i>fountain</i></b></div>","metadata":{}},{"cell_type":"code","source":"scene = 'fountain'\nsrc = f'/kaggle/input/image-matching-challenge-2023/train/{dataset}/{scene}'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:47.425199Z","iopub.execute_input":"2023-04-12T00:20:47.425636Z","iopub.status.idle":"2023-04-12T00:20:47.433385Z","shell.execute_reply.started":"2023-04-12T00:20:47.425595Z","shell.execute_reply":"2023-04-12T00:20:47.432011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"limit = 12\nimages = [cv2.cvtColor(cv2.imread(im), cv2.COLOR_BGR2RGB) for im in glob(f'{src}/images/*')[:limit]]\nmedia.show_images(images, height=300, columns=3)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:47.435330Z","iopub.execute_input":"2023-04-12T00:20:47.435713Z","iopub.status.idle":"2023-04-12T00:20:48.916839Z","shell.execute_reply.started":"2023-04-12T00:20:47.435657Z","shell.execute_reply":"2023-04-12T00:20:48.915173Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's plot a 3D map of the scene.</p>","metadata":{}},{"cell_type":"code","source":"rec_gt = pycolmap.Reconstruction(f'{src}/sfm')\n\nfig = viz_3d.init_figure()\n# viz_3d.plot_cameras(fig, rec_gt, color='rgba(50,255,50, 0.5)', name=\"Ground Truth\", size=10)\nviz_3d.plot_reconstruction(fig, rec_gt, cameras = False, color='rgba(224,220,211,0.5)', name=\"Ground Truth\", cs=5)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:20:48.918907Z","iopub.execute_input":"2023-04-12T00:20:48.919377Z","iopub.status.idle":"2023-04-12T00:20:53.052007Z","shell.execute_reply.started":"2023-04-12T00:20:48.919337Z","shell.execute_reply":"2023-04-12T00:20:53.047971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"3.2\"></a>\n## <div style=\"box-shadow: rgba(0, 0, 0, 0.18) 0px 2px 4px inset; padding:20px; font-size:24px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(67, 66, 66)\"> <b> 3.2 Scene <i>chairs</i></b></div>","metadata":{}},{"cell_type":"code","source":"scene = 'chairs'\nsrc = f'/kaggle/input/image-matching-challenge-2023/train/{dataset}/{scene}'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:53.053677Z","iopub.execute_input":"2023-04-12T00:20:53.054354Z","iopub.status.idle":"2023-04-12T00:20:53.060274Z","shell.execute_reply.started":"2023-04-12T00:20:53.054313Z","shell.execute_reply":"2023-04-12T00:20:53.058729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"limit = 12\nimages = [cv2.cvtColor(cv2.imread(im), cv2.COLOR_BGR2RGB) for im in glob(f'{src}/images/*')[:limit]]\nmedia.show_images(images, height=300, columns=3)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:53.062754Z","iopub.execute_input":"2023-04-12T00:20:53.063204Z","iopub.status.idle":"2023-04-12T00:20:54.570257Z","shell.execute_reply.started":"2023-04-12T00:20:53.063165Z","shell.execute_reply":"2023-04-12T00:20:54.568427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's plot a 3D map of the scene.</p>","metadata":{}},{"cell_type":"code","source":"rec_gt = pycolmap.Reconstruction(f'{src}/sfm')\n\nfig = viz_3d.init_figure()\n# viz_3d.plot_cameras(fig, rec_gt, color='rgba(50,255,50, 0.5)', name=\"Ground Truth\", size=10)\nviz_3d.plot_reconstruction(fig, rec_gt, cameras = False, color='rgba(103,143,114,0.5)', name=\"Ground Truth\", cs=5)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:20:54.571837Z","iopub.execute_input":"2023-04-12T00:20:54.572269Z","iopub.status.idle":"2023-04-12T00:20:57.388786Z","shell.execute_reply.started":"2023-04-12T00:20:54.572231Z","shell.execute_reply":"2023-04-12T00:20:57.386496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"3.3\"></a>\n## <div style=\"box-shadow: rgba(0, 0, 0, 0.18) 0px 2px 4px inset; padding:20px; font-size:24px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(67, 66, 66)\"> <b> 3.3 Scene <i>bike</i></b></div>","metadata":{}},{"cell_type":"code","source":"scene = 'bike'\nsrc = f'/kaggle/input/image-matching-challenge-2023/train/{dataset}/{scene}'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:57.391319Z","iopub.execute_input":"2023-04-12T00:20:57.392105Z","iopub.status.idle":"2023-04-12T00:20:57.397207Z","shell.execute_reply.started":"2023-04-12T00:20:57.392030Z","shell.execute_reply":"2023-04-12T00:20:57.396054Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"limit = 12\nimages = [cv2.cvtColor(cv2.imread(im), cv2.COLOR_BGR2RGB) for im in glob(f'{src}/images/*')[:limit]]\nmedia.show_images(images, height=300, columns=3)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:20:57.404686Z","iopub.execute_input":"2023-04-12T00:20:57.405600Z","iopub.status.idle":"2023-04-12T00:20:58.911516Z","shell.execute_reply.started":"2023-04-12T00:20:57.405547Z","shell.execute_reply":"2023-04-12T00:20:58.910478Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's plot a 3D map of the scene.</p>","metadata":{}},{"cell_type":"code","source":"rec_gt = pycolmap.Reconstruction(f'{src}/sfm')\n\nfig = viz_3d.init_figure()\n# viz_3d.plot_cameras(fig, rec_gt, color='rgba(50,255,50, 0.5)', name=\"Ground Truth\", size=10)\nviz_3d.plot_reconstruction(fig, rec_gt, cameras = False, color='rgba(156,153,140,0.5)', name=\"Ground Truth\", cs=5)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:20:58.912841Z","iopub.execute_input":"2023-04-12T00:20:58.913589Z","iopub.status.idle":"2023-04-12T00:21:01.520671Z","shell.execute_reply.started":"2023-04-12T00:20:58.913548Z","shell.execute_reply":"2023-04-12T00:21:01.517408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"4\"></a>\n# <div style=\"box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px inset, rgb(51, 51, 51) 0px 0px 0px 3px inset; padding:20px; font-size:32px; font-family: consolas; text-align:center; display:fill; border-radius:15px;  color:rgb(34, 34, 34);\"> <b> 4. Dataset <i>urban</i></b></div>","metadata":{}},{"cell_type":"code","source":"dataset = 'urban'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:21:01.522308Z","iopub.execute_input":"2023-04-12T00:21:01.522682Z","iopub.status.idle":"2023-04-12T00:21:01.528746Z","shell.execute_reply.started":"2023-04-12T00:21:01.522650Z","shell.execute_reply":"2023-04-12T00:21:01.527277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"4.1\"></a>\n## <div style=\"box-shadow: rgba(0, 0, 0, 0.18) 0px 2px 4px inset; padding:20px; font-size:24px; font-family: consolas; text-align:center; display:fill; border-radius:15px; color:rgb(67, 66, 66)\"> <b> 4.1 Scene <i>kyiv-puppet-theater</i></b></div>","metadata":{}},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">⚪ The Kyiv Puppet Theater is a theater located in Kyiv, Ukraine, that specializes in puppetry performances for children and adults. The theater was established in 1927 and has since become one of the most prominent puppet theaters in Ukraine.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">The Kyiv Puppet Theater features a wide variety of puppetry performances, including shows based on classic fairy tales and stories, as well as original productions created by the theater's talented artists and performers. The theater's repertoire includes both traditional and modern puppetry techniques, such as hand, rod, and shadow puppetry.</p>\n\n<p style=\"font-family: consolas; font-size: 16px;\">The Kyiv Puppet Theater is a beloved cultural institution in Ukraine, and its performances are enjoyed by both locals and tourists alike. If you are visiting Kyiv and want to experience the magic of puppetry, a visit to the Kyiv Puppet Theater is definitely worth considering.</p>","metadata":{}},{"cell_type":"code","source":"scene = 'kyiv-puppet-theater'\nsrc = f'/kaggle/input/image-matching-challenge-2023/train/{dataset}/{scene}'","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:21:01.530745Z","iopub.execute_input":"2023-04-12T00:21:01.531857Z","iopub.status.idle":"2023-04-12T00:21:01.543678Z","shell.execute_reply.started":"2023-04-12T00:21:01.531745Z","shell.execute_reply":"2023-04-12T00:21:01.541861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"limit = 12\nimages = [cv2.cvtColor(cv2.imread(im), cv2.COLOR_BGR2RGB) for im in glob(f'{src}/images/*')[:limit]]\nmedia.show_images(images, height=300, columns=3)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:21:01.545793Z","iopub.execute_input":"2023-04-12T00:21:01.546269Z","iopub.status.idle":"2023-04-12T00:21:03.094436Z","shell.execute_reply.started":"2023-04-12T00:21:01.546227Z","shell.execute_reply":"2023-04-12T00:21:03.093286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<p style=\"font-family: consolas; font-size: 16px;\">❔ Let's plot a 3D map of the scene.</p>","metadata":{}},{"cell_type":"code","source":"rec_gt = pycolmap.Reconstruction(f'{src}/sfm')\n\nfig = viz_3d.init_figure()\n# viz_3d.plot_cameras(fig, rec_gt, color='rgba(50,255,50, 0.5)', name=\"Ground Truth\", size=10)\nviz_3d.plot_reconstruction(fig, rec_gt, cameras = False, color='rgba(201,56,110,0.5)', name=\"Ground Truth\", cs=5)\nfig.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-04-12T00:21:03.096758Z","iopub.execute_input":"2023-04-12T00:21:03.097348Z","iopub.status.idle":"2023-04-12T00:21:07.557005Z","shell.execute_reply.started":"2023-04-12T00:21:03.097304Z","shell.execute_reply":"2023-04-12T00:21:07.554170Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# (⁠ ⁠ꈍ⁠ᴗ⁠ꈍ⁠) WORK STILL IN PROGRESS","metadata":{"execution":{"iopub.status.busy":"2023-04-12T00:21:07.559152Z","iopub.execute_input":"2023-04-12T00:21:07.559601Z","iopub.status.idle":"2023-04-12T00:21:07.567527Z","shell.execute_reply.started":"2023-04-12T00:21:07.559563Z","shell.execute_reply":"2023-04-12T00:21:07.565353Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <div style=\"box-shadow: rgba(240, 46, 170, 0.4) -5px 5px inset, rgba(240, 46, 170, 0.3) -10px 10px inset, rgba(240, 46, 170, 0.2) -15px 15px inset, rgba(240, 46, 170, 0.1) -20px 20px inset, rgba(240, 46, 170, 0.05) -25px 25px inset; padding:20px; font-size:30px; font-family: consolas; display:fill; border-radius:15px; color: rgba(240, 46, 170, 0.7)\"> <b> ༼⁠ ⁠つ⁠ ⁠◕⁠‿⁠◕⁠ ⁠༽⁠つ Thank You!</b></div>\n\n<p style=\"font-family:verdana; color:rgb(34, 34, 34); font-family: consolas; font-size: 16px;\"> 💌 Thank you for taking the time to read through my notebook. I hope you found it interesting and informative. If you have any feedback or suggestions for improvement, please don't hesitate to let me know in the comments. <br><br> 🚀 If you liked this notebook, please consider upvoting it so that others can discover it too. Your support means a lot to me, and it helps to motivate me to create more content in the future. <br><br> ❤️ Once again, thank you for your support, and I hope to see you again soon!</p>","metadata":{}}]}