{"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":"code","source":"import matplotlib.pyplot as plt\nimport os\nimport random","metadata":{"execution":{"iopub.status.busy":"2022-03-09T18:08:00.620165Z","iopub.execute_input":"2022-03-09T18:08:00.620471Z","iopub.status.idle":"2022-03-09T18:08:00.62463Z","shell.execute_reply.started":"2022-03-09T18:08:00.620437Z","shell.execute_reply":"2022-03-09T18:08:00.623733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Get the path of each image","metadata":{}},{"cell_type":"code","source":"def getPaths(basePath):\n    paths = []\n    for dirname, _, filenames in os.walk(basePath):\n        for filename in filenames:\n            path = os.path.join(dirname, filename)\n            paths.append(path)\n    return paths","metadata":{"execution":{"iopub.status.busy":"2022-03-09T18:04:34.697386Z","iopub.execute_input":"2022-03-09T18:04:34.697737Z","iopub.status.idle":"2022-03-09T18:04:34.710387Z","shell.execute_reply.started":"2022-03-09T18:04:34.697708Z","shell.execute_reply":"2022-03-09T18:04:34.709728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainImagesPaths = getPaths(\"/kaggle/input/happy-whale-and-dolphin/train_images\")","metadata":{"execution":{"iopub.status.busy":"2022-03-09T18:04:34.711543Z","iopub.execute_input":"2022-03-09T18:04:34.711895Z","iopub.status.idle":"2022-03-09T18:04:43.578015Z","shell.execute_reply.started":"2022-03-09T18:04:34.711868Z","shell.execute_reply":"2022-03-09T18:04:43.576865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# View images\n\nImages have a different shape and resolution!","metadata":{}},{"cell_type":"code","source":"def showImages(paths, nrows, ncols, height, width, seed = 0, dpi = 200):\n    fig = plt.figure(figsize = (width, height), dpi = dpi)\n    for i in range(0, nrows * ncols):\n        image = plt.imread(paths[i])\n        axis = fig.add_subplot(nrows, ncols, i + 1)\n        axis.set_axis_off()\n        plt.imshow(image)\n    plt.tight_layout()\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-09T18:19:56.373488Z","iopub.execute_input":"2022-03-09T18:19:56.373806Z","iopub.status.idle":"2022-03-09T18:19:56.380518Z","shell.execute_reply.started":"2022-03-09T18:19:56.373776Z","shell.execute_reply":"2022-03-09T18:19:56.379588Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nrows = 5\nncols = 5\nheight = 10\nwidth = 10\nimages = random.choices(trainImagesPaths, k = nrows * ncols)\nshowImages(images, nrows, ncols, height, width)","metadata":{"execution":{"iopub.status.busy":"2022-03-09T18:19:58.805313Z","iopub.execute_input":"2022-03-09T18:19:58.805965Z","iopub.status.idle":"2022-03-09T18:20:13.572174Z","shell.execute_reply.started":"2022-03-09T18:19:58.805927Z","shell.execute_reply":"2022-03-09T18:20:13.570813Z"},"trusted":true},"execution_count":null,"outputs":[]}]}