{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":71885,"databundleVersionId":8069805,"sourceType":"competition"}],"dockerImageVersionId":30673,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nfrom glob import glob\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-03-30T17:20:25.585126Z","iopub.execute_input":"2024-03-30T17:20:25.585970Z","iopub.status.idle":"2024-03-30T17:20:25.589394Z","shell.execute_reply.started":"2024-03-30T17:20:25.585937Z","shell.execute_reply":"2024-03-30T17:20:25.588647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_labels_df = pd.read_csv(\"/kaggle/input/image-matching-challenge-2024/train/train_labels.csv\")\ntrain_labels_df","metadata":{"execution":{"iopub.status.busy":"2024-03-30T17:19:21.993296Z","iopub.execute_input":"2024-03-30T17:19:21.993699Z","iopub.status.idle":"2024-03-30T17:19:22.024074Z","shell.execute_reply.started":"2024-03-30T17:19:21.993671Z","shell.execute_reply":"2024-03-30T17:19:22.023080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"categories_df = pd.read_csv(\"/kaggle/input/image-matching-challenge-2024/train/categories.csv\")\nscenes = categories_df[\"scene\"].values.tolist()\nscenes","metadata":{"execution":{"iopub.status.busy":"2024-03-30T17:20:09.448872Z","iopub.execute_input":"2024-03-30T17:20:09.449905Z","iopub.status.idle":"2024-03-30T17:20:09.459801Z","shell.execute_reply.started":"2024-03-30T17:20:09.449871Z","shell.execute_reply":"2024-03-30T17:20:09.458898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Check","metadata":{}},{"cell_type":"code","source":"for scene in scenes:\n    print(f\"===== {scene} =====\")\n    img_list = glob(f\"/kaggle/input/image-matching-challenge-2024/train/{scene}/images/*.png\")\n    img_list = [os.path.basename(p) for p in img_list]\n    \n    df = train_labels_df.query(\"scene==@scene\")\n    df_img_list = df[\"image_name\"].values.tolist()\n    \n    img_list = set(img_list)\n    df_img_list = set(df_img_list)\n    \n    set1 = img_list-df_img_list    # Image exists but not in csv\n    print(\"Image exists but not in csv\")\n    print(f\"num = {len(set1)}\")\n    for p in list(set1):\n        print(f\"  {p}\")\n    print(\"\")\n    \n    \n    set2 = df_img_list-img_list    # Image does not exist, but exists in csv\n    print(\"Image does not exist, but exists in csv\")\n    print(f\"num = {len(set2)}\")\n    for p in list(set2):\n        print(f\"  {p}\")\n    print(\"\")","metadata":{"execution":{"iopub.status.busy":"2024-03-30T17:38:08.733934Z","iopub.execute_input":"2024-03-30T17:38:08.734314Z","iopub.status.idle":"2024-03-30T17:38:08.779204Z","shell.execute_reply.started":"2024-03-30T17:38:08.734269Z","shell.execute_reply":"2024-03-30T17:38:08.778393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Example of an image that exists but does not exist in csv","metadata":{}},{"cell_type":"code","source":"path = \"/kaggle/input/image-matching-challenge-2024/train/church/images/00036.png\"\nis_file = os.path.isfile(path)\nprint(is_file)\n\nbasename = os.path.basename(path)\ndf = train_labels_df.query(\"image_name==@basename and scene=='church'\")\nprint(len(df))","metadata":{"execution":{"iopub.status.busy":"2024-03-30T17:43:40.240419Z","iopub.execute_input":"2024-03-30T17:43:40.240795Z","iopub.status.idle":"2024-03-30T17:43:40.251633Z","shell.execute_reply.started":"2024-03-30T17:43:40.240766Z","shell.execute_reply":"2024-03-30T17:43:40.250464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = \"/kaggle/input/image-matching-challenge-2024/train/multi-temporal-temple-baalshamin/images/PICT0810.png\"\nis_file = os.path.isfile(path)\nprint(is_file)\n\nbasename = os.path.basename(path)\ndf = train_labels_df.query(\"image_name==@basename and scene=='multi-temporal-temple-baalshamin'\")\nprint(len(df))","metadata":{"execution":{"iopub.status.busy":"2024-03-30T17:44:20.542374Z","iopub.execute_input":"2024-03-30T17:44:20.542952Z","iopub.status.idle":"2024-03-30T17:44:20.556946Z","shell.execute_reply.started":"2024-03-30T17:44:20.542923Z","shell.execute_reply":"2024-03-30T17:44:20.555832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Example of an image that does not exist but exists in csv","metadata":{}},{"cell_type":"code","source":"path = \"/kaggle/input/image-matching-challenge-2024/train/lizard/images/00574.png\"\nis_file = os.path.isfile(path)\nprint(is_file)\n\nbasename = os.path.basename(path)\ndf = train_labels_df.query(\"image_name==@basename and scene=='lizard'\")\nprint(len(df))","metadata":{"execution":{"iopub.status.busy":"2024-03-30T17:44:59.988238Z","iopub.execute_input":"2024-03-30T17:44:59.988598Z","iopub.status.idle":"2024-03-30T17:45:00.010697Z","shell.execute_reply.started":"2024-03-30T17:44:59.988572Z","shell.execute_reply":"2024-03-30T17:45:00.009808Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = \"/kaggle/input/image-matching-challenge-2024/train/multi-temporal-temple-baalshamin/images/temle-ba'al-shamin-4.png\"\nis_file = os.path.isfile(path)\nprint(is_file)\n\nbasename = os.path.basename(path)\ndf = train_labels_df.query(\"image_name==@basename and scene=='multi-temporal-temple-baalshamin'\")\nprint(len(df))","metadata":{"execution":{"iopub.status.busy":"2024-03-30T17:45:37.095252Z","iopub.execute_input":"2024-03-30T17:45:37.096411Z","iopub.status.idle":"2024-03-30T17:45:37.111681Z","shell.execute_reply.started":"2024-03-30T17:45:37.096367Z","shell.execute_reply":"2024-03-30T17:45:37.110752Z"},"trusted":true},"execution_count":null,"outputs":[]}]}