{"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":11821114,"sourceType":"datasetVersion","datasetId":7425337},{"sourceId":11862553,"sourceType":"datasetVersion","datasetId":7454270}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"editable":false,"execution":{"iopub.status.busy":"2025-05-19T17:15:34.301898Z","iopub.execute_input":"2025-05-19T17:15:34.302215Z","iopub.status.idle":"2025-05-19T17:15:34.309540Z","shell.execute_reply.started":"2025-05-19T17:15:34.302193Z","shell.execute_reply":"2025-05-19T17:15:34.308491Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# installing the Kaggle library\n!pip install kaggle","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:15:34.312148Z","iopub.execute_input":"2025-05-19T17:15:34.312486Z","iopub.status.idle":"2025-05-19T17:15:38.128370Z","shell.execute_reply.started":"2025-05-19T17:15:34.312457Z","shell.execute_reply":"2025-05-19T17:15:38.127253Z"},"editable":false},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!mkdir -p ~/.kaggle\n!cp /kaggle/input/kaggle-json/kaggle.json ~/.kaggle/\n!chmod 600 ~/.kaggle/kaggle.json\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:15:38.129641Z","iopub.execute_input":"2025-05-19T17:15:38.129999Z","iopub.status.idle":"2025-05-19T17:15:38.491290Z","shell.execute_reply.started":"2025-05-19T17:15:38.129968Z","shell.execute_reply":"2025-05-19T17:15:38.489982Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Kaggle api \n!kaggle competitions download -c dogs-vs-cats","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:15:38.492686Z","iopub.execute_input":"2025-05-19T17:15:38.493040Z","iopub.status.idle":"2025-05-19T17:16:00.854578Z","shell.execute_reply.started":"2025-05-19T17:15:38.493011Z","shell.execute_reply":"2025-05-19T17:16:00.853323Z"},"editable":false},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:16:00.855929Z","iopub.execute_input":"2025-05-19T17:16:00.856289Z","iopub.status.idle":"2025-05-19T17:16:00.981261Z","shell.execute_reply.started":"2025-05-19T17:16:00.856246Z","shell.execute_reply":"2025-05-19T17:16:00.980163Z"},"editable":false},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from zipfile import ZipFile\n\ndataset = '/kaggle/working/dogs-vs-cats.zip'\n\nwith ZipFile(dataset, 'r') as zip:\n  zip.extractall()\n  print('The dataset is extracted')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:16:00.982898Z","iopub.execute_input":"2025-05-19T17:16:00.983293Z","iopub.status.idle":"2025-05-19T17:16:05.325431Z","shell.execute_reply.started":"2025-05-19T17:16:00.983252Z","shell.execute_reply":"2025-05-19T17:16:05.324196Z"},"editable":false},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from zipfile import ZipFile\nimport os\n\nzip_path = '/kaggle/working/train.zip'\nextract_to = '/kaggle/working/train'  # Folder where you want the data\n\n# Create the folder if it doesn't exist\nos.makedirs(extract_to, exist_ok=True)\n\n# Extract zip contents\nwith ZipFile(zip_path, 'r') as zip_ref:\n    zip_ref.extractall(extract_to)\n\nprint(\"✅ train.zip extracted to:\", extract_to)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:16:05.326517Z","iopub.execute_input":"2025-05-19T17:16:05.326870Z","iopub.status.idle":"2025-05-19T17:16:13.384070Z","shell.execute_reply.started":"2025-05-19T17:16:05.326840Z","shell.execute_reply":"2025-05-19T17:16:13.382911Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for root, dirs, files in os.walk('/kaggle/working/train'):\n    print(\"📂 Directory:\", root)\n    print(\"📁 Subdirectories:\", dirs)\n    print(\"📄 Files:\", files[:5])  # only show first 5 files\n    break\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:16:13.392528Z","iopub.execute_input":"2025-05-19T17:16:13.392911Z","iopub.status.idle":"2025-05-19T17:16:13.404129Z","shell.execute_reply.started":"2025-05-19T17:16:13.392880Z","shell.execute_reply":"2025-05-19T17:16:13.402192Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image_dir = '/kaggle/working/train/train'  # Note the second 'train'\n\nfile_count = len([\n    f for f in os.listdir(image_dir)\n    if os.path.isfile(os.path.join(image_dir, f))\n])\n\nprint(\"📸 Number of images:\", file_count)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:16:13.437886Z","iopub.execute_input":"2025-05-19T17:16:13.440901Z","iopub.status.idle":"2025-05-19T17:16:13.642949Z","shell.execute_reply.started":"2025-05-19T17:16:13.440857Z","shell.execute_reply":"2025-05-19T17:16:13.641634Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# import os\n# # counting the number of files in train folder\n# path, dirs, files = next(os.walk('/kaggle/working/train.zip'))\n# file_count = len(files)\n# print('Number of images: ', file_count)\n\nimport os\n\n# Adjust this path if the ZIP extracted into a folder inside working\nextracted_path = '/kaggle/working/train/train'\n\n# Check how many image files are there\nfile_count = len([f for f in os.listdir(extracted_path) if os.path.isfile(os.path.join(extracted_path, f))])\nprint('Number of images:', file_count)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:16:13.644439Z","iopub.execute_input":"2025-05-19T17:16:13.644744Z","iopub.status.idle":"2025-05-19T17:16:13.831501Z","shell.execute_reply.started":"2025-05-19T17:16:13.644697Z","shell.execute_reply":"2025-05-19T17:16:13.830207Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"file_names = os.listdir('/kaggle/working/train/train')\nprint(file_names)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-19T17:16:13.832794Z","iopub.execute_input":"2025-05-19T17:16:13.833083Z","iopub.status.idle":"2025-05-19T17:16:13.863462Z","shell.execute_reply.started":"2025-05-19T17:16:13.833054Z","shell.execute_reply":"2025-05-19T17:16:13.862134Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"editable":false},"outputs":[],"execution_count":null}]}