{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":3362,"databundleVersionId":31148,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# import the zipfile library\nimport zipfile","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-01T05:04:18.945029Z","iopub.execute_input":"2025-06-01T05:04:18.945314Z","iopub.status.idle":"2025-06-01T05:04:18.950063Z","shell.execute_reply.started":"2025-06-01T05:04:18.945287Z","shell.execute_reply":"2025-06-01T05:04:18.949065Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Zipfile location\nzip_file_directory = \"/kaggle/input/dogs-vs-cats/train.zip\"\n\n# Extracted file location\nextract_directory = \"/kaggle/working/\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-01T05:04:21.395314Z","iopub.execute_input":"2025-06-01T05:04:21.395618Z","iopub.status.idle":"2025-06-01T05:04:21.400014Z","shell.execute_reply.started":"2025-06-01T05:04:21.395592Z","shell.execute_reply":"2025-06-01T05:04:21.398972Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Extract the zipfile\nwith zipfile.ZipFile(zip_file_directory, \"r\") as files:\n    files.extractall(extract_directory)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-01T05:04:25.777036Z","iopub.execute_input":"2025-06-01T05:04:25.777343Z","iopub.status.idle":"2025-06-01T05:04:34.866612Z","shell.execute_reply.started":"2025-06-01T05:04:25.777319Z","shell.execute_reply":"2025-06-01T05:04:34.865944Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Get the files path\n\n# import os library\nimport os\n\n# list all the files in \"train folder\"\nlist_files = os.listdir(\"/kaggle/working/train/\")\n\n# create a list of each files, so we can access/open it\nfiles_path = []\nfor f in list_files:\n    files_path.append(os.path.join(\"/kaggle/working/train/\", f))\n\n# preview the first five files path\nfiles_path[:5]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-01T05:08:40.624310Z","iopub.execute_input":"2025-06-01T05:08:40.624971Z","iopub.status.idle":"2025-06-01T05:08:40.666052Z","shell.execute_reply.started":"2025-06-01T05:08:40.624938Z","shell.execute_reply":"2025-06-01T05:08:40.665206Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# randomly preview one file\nfrom PIL import Image\nimport random\n\nrandom_image_path = random.choice(files_path)\nimg = Image.open(random_image_path)\nimg","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-01T05:09:35.707862Z","iopub.execute_input":"2025-06-01T05:09:35.708158Z","iopub.status.idle":"2025-06-01T05:09:35.751514Z","shell.execute_reply.started":"2025-06-01T05:09:35.708136Z","shell.execute_reply":"2025-06-01T05:09:35.750683Z"}},"outputs":[],"execution_count":null}]}