{"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":"# Smallest dataset for downloading\n* ## all the thumbnail images are included meanwhile only the TMI images from train_images are included","metadata":{}},{"cell_type":"code","source":"!cp -r /kaggle/input/UBC-OCEAN/train_thumbnails .\n!cp -r /kaggle/input/UBC-OCEAN/test_images .\n!cp -r /kaggle/input/UBC-OCEAN/test_thumbnails .\n!cp -r /kaggle/input/UBC-OCEAN/*.csv .\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-10-09T17:03:22.355419Z","iopub.execute_input":"2023-10-09T17:03:22.356Z","iopub.status.idle":"2023-10-09T17:04:04.207207Z","shell.execute_reply.started":"2023-10-09T17:03:22.355962Z","shell.execute_reply":"2023-10-09T17:04:04.205852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import shutil\nimport pandas as pd\nimport os\n","metadata":{"execution":{"iopub.status.busy":"2023-10-09T17:06:43.179341Z","iopub.execute_input":"2023-10-09T17:06:43.180389Z","iopub.status.idle":"2023-10-09T17:06:43.185113Z","shell.execute_reply.started":"2023-10-09T17:06:43.180347Z","shell.execute_reply":"2023-10-09T17:06:43.183961Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/UBC-OCEAN/train.csv\")\nROOT_DIR = '/kaggle/input/UBC-OCEAN'\nTRAIN_DIR = '/kaggle/input/UBC-OCEAN/train_thumbnails'\nALT_TEST_DIR = '/kaggle/input/UBC-OCEAN/test_images'\nTEST_DIR = '/kaggle/input/UBC-OCEAN/test_thumbnails'\nALT_TRAIN_DIR = '/kaggle/input/UBC-OCEAN/train_images'\n# test_df = pd.read_csv(\"/kaggle/input/UBC-OCEAN/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-10-09T17:06:20.829038Z","iopub.execute_input":"2023-10-09T17:06:20.829457Z","iopub.status.idle":"2023-10-09T17:06:20.837845Z","shell.execute_reply.started":"2023-10-09T17:06:20.829415Z","shell.execute_reply":"2023-10-09T17:06:20.83695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_train_file_path(image_id):\n    if os.path.exists(f\"{TRAIN_DIR}/{image_id}_thumbnail.png\"):\n        return f\"{TRAIN_DIR}/{image_id}_thumbnail.png\"\n    else:\n        return f\"{ALT_TRAIN_DIR}/{image_id}.png\"","metadata":{"execution":{"iopub.status.busy":"2023-10-09T17:06:22.67604Z","iopub.execute_input":"2023-10-09T17:06:22.676373Z","iopub.status.idle":"2023-10-09T17:06:22.681957Z","shell.execute_reply.started":"2023-10-09T17:06:22.676346Z","shell.execute_reply":"2023-10-09T17:06:22.68057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['file_path'] = df['image_id'].apply(get_train_file_path)","metadata":{"execution":{"iopub.status.busy":"2023-10-09T17:06:44.973826Z","iopub.execute_input":"2023-10-09T17:06:44.974219Z","iopub.status.idle":"2023-10-09T17:06:45.308725Z","shell.execute_reply.started":"2023-10-09T17:06:44.974188Z","shell.execute_reply":"2023-10-09T17:06:45.307556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.makedirs(\"./train_images/\")","metadata":{"execution":{"iopub.status.busy":"2023-10-09T17:08:08.925678Z","iopub.execute_input":"2023-10-09T17:08:08.926134Z","iopub.status.idle":"2023-10-09T17:08:09.02708Z","shell.execute_reply.started":"2023-10-09T17:08:08.926096Z","shell.execute_reply":"2023-10-09T17:08:09.025595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rest_files = [f for f in df['file_path'] if \"thumbnail\" not in f]","metadata":{"execution":{"iopub.status.busy":"2023-10-09T17:08:32.433738Z","iopub.execute_input":"2023-10-09T17:08:32.434133Z","iopub.status.idle":"2023-10-09T17:08:32.439823Z","shell.execute_reply.started":"2023-10-09T17:08:32.434102Z","shell.execute_reply":"2023-10-09T17:08:32.438793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for file in rest_files:\n    shutil.copy(file,\"./train_images/\")","metadata":{"execution":{"iopub.status.busy":"2023-10-09T17:09:22.910406Z","iopub.execute_input":"2023-10-09T17:09:22.910915Z","iopub.status.idle":"2023-10-09T17:09:29.70412Z","shell.execute_reply.started":"2023-10-09T17:09:22.910882Z","shell.execute_reply":"2023-10-09T17:09:29.70253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}