{"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":9988,"databundleVersionId":868324,"sourceType":"competition"}],"dockerImageVersionId":30684,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd \nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-09T20:38:03.653058Z","iopub.execute_input":"2024-04-09T20:38:03.653472Z","iopub.status.idle":"2024-04-09T20:38:06.312348Z","shell.execute_reply.started":"2024-04-09T20:38:03.653437Z","shell.execute_reply":"2024-04-09T20:38:06.311213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Airbus Ship Detection Challenge**","metadata":{}},{"cell_type":"code","source":"ls ../input/\n","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:30:13.194201Z","iopub.execute_input":"2024-04-09T20:30:13.194701Z","iopub.status.idle":"2024-04-09T20:30:14.250149Z","shell.execute_reply.started":"2024-04-09T20:30:13.194645Z","shell.execute_reply":"2024-04-09T20:30:14.248418Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = os.listdir(\"/kaggle/input/airbus-ship-detection/train_v2\")\ntest = os.listdir(\"/kaggle/input/airbus-ship-detection/test_v2\")\n\nprint(f\"Train files: {len(train)}\")\nprint(f\"Test files :  {len(test)}\")","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:32:39.801132Z","iopub.execute_input":"2024-04-09T20:32:39.801599Z","iopub.status.idle":"2024-04-09T20:32:39.918992Z","shell.execute_reply.started":"2024-04-09T20:32:39.801569Z","shell.execute_reply":"2024-04-09T20:32:39.917772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The data contain roughly 200,000 and 15,000 images each for training and testing. ","metadata":{}},{"cell_type":"markdown","source":"# Image Display","metadata":{}},{"cell_type":"markdown","source":"Lets understand our data and lets use the library PIL to visualize geospatial images.","metadata":{}},{"cell_type":"code","source":"import PIL \n\nimage_test_path = '/kaggle/input/airbus-ship-detection/train_v2/000532683.jpg'\n\nPIL.Image.open(image_test_path)\n","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:37:21.309342Z","iopub.execute_input":"2024-04-09T20:37:21.309732Z","iopub.status.idle":"2024-04-09T20:37:21.589010Z","shell.execute_reply.started":"2024-04-09T20:37:21.309701Z","shell.execute_reply":"2024-04-09T20:37:21.587704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PIL.Image.open(image_test_path).size","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:37:25.052632Z","iopub.execute_input":"2024-04-09T20:37:25.053067Z","iopub.status.idle":"2024-04-09T20:37:25.063086Z","shell.execute_reply.started":"2024-04-09T20:37:25.053033Z","shell.execute_reply":"2024-04-09T20:37:25.061243Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = PIL.Image.open(image_test_path).resize((500, 500))\n\nrgb_pixels = np.array(img)\nrgb_pixels.shape","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:39:23.108259Z","iopub.execute_input":"2024-04-09T20:39:23.109022Z","iopub.status.idle":"2024-04-09T20:39:23.136742Z","shell.execute_reply.started":"2024-04-09T20:39:23.108986Z","shell.execute_reply":"2024-04-09T20:39:23.135949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rgb_pixels[0:2, 0:2, 0]","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:39:25.038077Z","iopub.execute_input":"2024-04-09T20:39:25.038727Z","iopub.status.idle":"2024-04-09T20:39:25.047082Z","shell.execute_reply.started":"2024-04-09T20:39:25.038673Z","shell.execute_reply":"2024-04-09T20:39:25.045762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(rgb_pixels)","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:39:39.482796Z","iopub.execute_input":"2024-04-09T20:39:39.483380Z","iopub.status.idle":"2024-04-09T20:39:39.907068Z","shell.execute_reply.started":"2024-04-09T20:39:39.483348Z","shell.execute_reply":"2024-04-09T20:39:39.905939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Multiple Displaying","metadata":{}},{"cell_type":"code","source":"# these two variables are \"the parameters\" of this cell\ncolums = 6\nrows = 6\n\n# this function uses the open, resize and array functions we have seen before\nload_img = lambda filename: np.array(PIL.Image.open(f\"/kaggle/input/airbus-ship-detection/train_v2/{filename}\").resize((500, 500)))\n\n_, axes_list = plt.subplots(colums, rows, figsize=(2*rows, 2*colums)) \n\nfor axes in axes_list:\n    for ax in axes:\n        ax.axis('off')\n        img = np.random.choice(train) # take a random filename \n        ax.imshow(load_img(img)) \n        ax.set_title(img)","metadata":{"execution":{"iopub.status.busy":"2024-04-09T20:42:47.083400Z","iopub.execute_input":"2024-04-09T20:42:47.083898Z","iopub.status.idle":"2024-04-09T20:42:54.295161Z","shell.execute_reply.started":"2024-04-09T20:42:47.083863Z","shell.execute_reply":"2024-04-09T20:42:54.294230Z"},"trusted":true},"execution_count":null,"outputs":[]}]}