{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":4104,"databundleVersionId":46661,"sourceType":"competition"}],"dockerImageVersionId":31154,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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,"execution":{"iopub.status.busy":"2025-10-10T07:25:11.087334Z","iopub.execute_input":"2025-10-10T07:25:11.087767Z","iopub.status.idle":"2025-10-10T07:25:11.094219Z","shell.execute_reply.started":"2025-10-10T07:25:11.087743Z","shell.execute_reply":"2025-10-10T07:25:11.093352Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!mkdir -p /kaggle/working/data/train /kaggle/working/data/test /kaggle/working/cache\n\nimport os, shutil, glob, zipfile, random\nfrom pathlib import Path\nimport numpy as np\nimport pandas as pd\nfrom PIL import Image\nimport cv2\n\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import Dataset, DataLoader\nfrom torchvision import transforms, models\n\nfrom sklearn.model_selection import GroupKFold\nfrom sklearn.metrics import cohen_kappa_score\n\nSEED = 42\nrandom.seed(SEED); np.random.seed(SEED); torch.manual_seed(SEED); torch.cuda.manual_seed_all(SEED)\nDEVICE = \"cuda\" if torch.cuda.is_available() else \"cpu\"\nprint(\"Device:\", DEVICE)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-10T07:25:11.095686Z","iopub.execute_input":"2025-10-10T07:25:11.095917Z","iopub.status.idle":"2025-10-10T07:25:11.263051Z","shell.execute_reply.started":"2025-10-10T07:25:11.095884Z","shell.execute_reply":"2025-10-10T07:25:11.262205Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import shutil\n\n# Step 1: Clean up working directory to avoid overflow\nshutil.rmtree(\"/kaggle/working/data/train\", ignore_errors=True)\nshutil.rmtree(\"/kaggle/working/data/test\", ignore_errors=True)\nshutil.rmtree(\"/kaggle/working/cache\", ignore_errors=True)\n\n!mkdir -p /kaggle/working/data/train /kaggle/working/data/test /kaggle/working/cache\n\n# Step 2: Controlled extraction\nMAX_TRAIN_FILES = 8000   # Adjust this downward if you face space issues\nMAX_TEST_FILES = 2000\n\nassemble_and_extract(\"/kaggle/input/diabetic-retinopathy-detection/train.zip\", \"/kaggle/working/data/train\", max_files=MAX_TRAIN_FILES)\nassemble_and_extract(\"/kaggle/input/diabetic-retinopathy-detection/test.zip\", \"/kaggle/working/data/test\", max_files=MAX_TEST_FILES)\n\n# Step 3: Check disk usage after extraction\n!df -h /kaggle/working\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-10T07:31:05.752041Z","iopub.execute_input":"2025-10-10T07:31:05.752352Z","iopub.status.idle":"2025-10-10T07:33:27.96355Z","shell.execute_reply.started":"2025-10-10T07:31:05.752329Z","shell.execute_reply":"2025-10-10T07:33:27.962541Z"}},"outputs":[],"execution_count":null}]}