{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":28755,"isInternetEnabled":false,"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\n\n# Use the kagglehub client library to attach Kaggle resources like competitions, datasets, and models to your session\n# Learn more about kagglehub: https://github.com/Kaggle/kagglehub/blob/main/README.md\n\nimport kagglehub\n# kagglehub.dataset_download('<owner>/<dataset-slug>')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git clone https://github.com/hahammad01/ich-cloud.git\n%cd ich-cloud\n!pip install -q -r requirements.txt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T07:10:53.281187Z","iopub.execute_input":"2026-08-04T07:10:53.281746Z","iopub.status.idle":"2026-08-04T07:10:58.22169Z","shell.execute_reply.started":"2026-08-04T07:10:53.281707Z","shell.execute_reply":"2026-08-04T07:10:58.220947Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!find /kaggle/input -maxdepth 3 -name \"stage_2_train.csv\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T07:53:57.658629Z","iopub.execute_input":"2026-08-04T07:53:57.659397Z","iopub.status.idle":"2026-08-04T07:53:57.776549Z","shell.execute_reply.started":"2026-08-04T07:53:57.65936Z","shell.execute_reply":"2026-08-04T07:53:57.775782Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/ich-cloud\n!git pull\n!python -c \"import config as C; print('DATA_ROOT =', C.DATA_ROOT); print('labels CSV found:', C.TRAIN_CSV.exists()); print('image folder found:', C.TRAIN_DIR.exists())\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T08:02:18.126606Z","iopub.execute_input":"2026-08-04T08:02:18.127098Z","iopub.status.idle":"2026-08-04T08:02:18.673698Z","shell.execute_reply.started":"2026-08-04T08:02:18.127064Z","shell.execute_reply":"2026-08-04T08:02:18.672982Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/ich-cloud\n!git pull\n!python -c \"import config as C; print('DATA_ROOT =', C.DATA_ROOT); print('labels CSV found:', C.TRAIN_CSV.exists()); print('image folder found:', C.TRAIN_DIR.exists())\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T08:07:29.603615Z","iopub.execute_input":"2026-08-04T08:07:29.604596Z","iopub.status.idle":"2026-08-04T08:07:30.160836Z","shell.execute_reply.started":"2026-08-04T08:07:29.604558Z","shell.execute_reply":"2026-08-04T08:07:30.160049Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls -la \"/kaggle/input/competitions/rsna-intracranial-hemorrhage-detection/rsna-intracranial-hemorrhage-detection\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T08:08:06.493066Z","iopub.execute_input":"2026-08-04T08:08:06.493944Z","iopub.status.idle":"2026-08-04T08:08:06.617538Z","shell.execute_reply.started":"2026-08-04T08:08:06.493906Z","shell.execute_reply":"2026-08-04T08:08:06.616536Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git pull\n!python -c \"import config as C; print('DATA_ROOT =', C.DATA_ROOT); print('CSV:', C.TRAIN_CSV.exists(), '| images:', C.TRAIN_DIR.exists()); print('TRAIN_DIR =', C.TRAIN_DIR)\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T08:08:24.590653Z","iopub.execute_input":"2026-08-04T08:08:24.591366Z","iopub.status.idle":"2026-08-04T08:08:25.097576Z","shell.execute_reply.started":"2026-08-04T08:08:24.591329Z","shell.execute_reply":"2026-08-04T08:08:25.096869Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python prepare_data.py","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T08:09:17.069772Z","iopub.execute_input":"2026-08-04T08:09:17.070698Z","iopub.status.idle":"2026-08-04T08:57:21.405832Z","shell.execute_reply.started":"2026-08-04T08:09:17.070662Z","shell.execute_reply":"2026-08-04T08:57:21.405118Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python train.py --model resnet50\n!python train.py --model efficientnet_b0\n!python evaluate.py --model efficientnet_b0 --threshold 0.5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T09:08:37.662659Z","iopub.execute_input":"2026-08-04T09:08:37.663503Z","iopub.status.idle":"2026-08-04T09:09:25.191143Z","shell.execute_reply.started":"2026-08-04T09:08:37.663468Z","shell.execute_reply":"2026-08-04T09:09:25.190438Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working\n!git -C ich-cloud pull || git clone https://github.com/hahammad01/ich-cloud.git\n%cd /kaggle/working/ich-cloud\n!pip install -q -r requirements.txt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T09:15:14.37099Z","iopub.execute_input":"2026-08-04T09:15:14.37157Z","iopub.status.idle":"2026-08-04T09:15:20.392073Z","shell.execute_reply.started":"2026-08-04T09:15:14.371489Z","shell.execute_reply":"2026-08-04T09:15:20.391078Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import torch\nprint(torch.cuda.get_device_name(0))\nx = torch.randn(8, 3, 64, 64, device=\"cuda\")\nprint(\"gpu ok:\", float((x * 2).sum()))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T09:15:21.760145Z","iopub.execute_input":"2026-08-04T09:15:21.760946Z","iopub.status.idle":"2026-08-04T09:15:27.05002Z","shell.execute_reply.started":"2026-08-04T09:15:21.760903Z","shell.execute_reply":"2026-08-04T09:15:27.0492Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python prepare_data.py","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T09:15:40.604898Z","iopub.execute_input":"2026-08-04T09:15:40.605448Z","iopub.status.idle":"2026-08-04T10:13:42.638193Z","shell.execute_reply.started":"2026-08-04T09:15:40.605417Z","shell.execute_reply":"2026-08-04T10:13:42.637326Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python train.py --model resnet50","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T10:45:34.351799Z","iopub.execute_input":"2026-08-04T10:45:34.352118Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/ich-cloud\n!git pull","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T12:44:24.972665Z","iopub.execute_input":"2026-08-04T12:44:24.973078Z","iopub.status.idle":"2026-08-04T12:44:25.856251Z","shell.execute_reply.started":"2026-08-04T12:44:24.973037Z","shell.execute_reply":"2026-08-04T12:44:25.85535Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python -c \"import config as C; print('EPOCHS =', C.EPOCHS)\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T12:44:41.529179Z","iopub.execute_input":"2026-08-04T12:44:41.530476Z","iopub.status.idle":"2026-08-04T12:44:41.785921Z","shell.execute_reply.started":"2026-08-04T12:44:41.530422Z","shell.execute_reply":"2026-08-04T12:44:41.784786Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python train.py --model resnet50","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T12:45:12.285039Z","iopub.execute_input":"2026-08-04T12:45:12.286225Z","iopub.status.idle":"2026-08-04T13:25:09.494397Z","shell.execute_reply.started":"2026-08-04T12:45:12.286186Z","shell.execute_reply":"2026-08-04T13:25:09.493412Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python train.py --model efficientnet_b0","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T14:48:41.415461Z","iopub.execute_input":"2026-08-04T14:48:41.415988Z","iopub.status.idle":"2026-08-04T14:48:47.765199Z","shell.execute_reply.started":"2026-08-04T14:48:41.415946Z","shell.execute_reply":"2026-08-04T14:48:47.764311Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls /kaggle/working/ich-cloud/work","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T14:58:37.178858Z","iopub.execute_input":"2026-08-04T14:58:37.179279Z","iopub.status.idle":"2026-08-04T14:58:37.378669Z","shell.execute_reply.started":"2026-08-04T14:58:37.179245Z","shell.execute_reply":"2026-08-04T14:58:37.377458Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python -u train.py --model efficientnet_b0","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T14:58:59.994185Z","iopub.execute_input":"2026-08-04T14:58:59.994522Z","iopub.status.idle":"2026-08-04T15:34:16.535223Z","shell.execute_reply.started":"2026-08-04T14:58:59.994472Z","shell.execute_reply":"2026-08-04T15:34:16.533926Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python evaluate.py --model efficientnet_b0 --threshold 0.5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T15:35:52.189252Z","iopub.execute_input":"2026-08-04T15:35:52.190097Z","iopub.status.idle":"2026-08-04T15:36:05.45696Z","shell.execute_reply.started":"2026-08-04T15:35:52.190048Z","shell.execute_reply":"2026-08-04T15:36:05.455815Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git pull\n!python evaluate.py --model efficientnet_b0 --threshold 0.5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T15:38:03.678401Z","iopub.execute_input":"2026-08-04T15:38:03.67896Z","iopub.status.idle":"2026-08-04T15:41:33.386523Z","shell.execute_reply.started":"2026-08-04T15:38:03.678922Z","shell.execute_reply":"2026-08-04T15:41:33.38559Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!git pull","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T15:41:44.333481Z","iopub.execute_input":"2026-08-04T15:41:44.333828Z","iopub.status.idle":"2026-08-04T15:41:44.740383Z","shell.execute_reply.started":"2026-08-04T15:41:44.333796Z","shell.execute_reply":"2026-08-04T15:41:44.739522Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python evaluate.py --model resnet50 --threshold 0.5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T15:41:51.500197Z","iopub.execute_input":"2026-08-04T15:41:51.501145Z","iopub.status.idle":"2026-08-04T15:44:58.352567Z","shell.execute_reply.started":"2026-08-04T15:41:51.501088Z","shell.execute_reply":"2026-08-04T15:44:58.351661Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python evaluate.py --model efficientnet_b0 --threshold 0.5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-04T15:45:13.568629Z","iopub.execute_input":"2026-08-04T15:45:13.569138Z","iopub.status.idle":"2026-08-04T15:47:58.357044Z","shell.execute_reply.started":"2026-08-04T15:45:13.5691Z","shell.execute_reply":"2026-08-04T15:47:58.356153Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working\n!git -C ich-cloud pull || git clone https://github.com/hahammad01/ich-cloud.git\n%cd /kaggle/working/ich-cloud\n!pip install -q -r requirements.txt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-05T06:59:40.959133Z","iopub.execute_input":"2026-08-05T06:59:40.959416Z","iopub.status.idle":"2026-08-05T06:59:46.460395Z","shell.execute_reply.started":"2026-08-05T06:59:40.959369Z","shell.execute_reply":"2026-08-05T06:59:46.459454Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python -c \"import config as C; print('SUBSET =', C.SUBSET_N_PATIENTS, '| EPOCHS =', C.EPOCHS, '| WORKERS =', C.NUM_WORKERS); print('CSV:', C.TRAIN_CSV.exists(), '| images:', C.TRAIN_DIR.exists())\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-05T07:00:19.470693Z","iopub.execute_input":"2026-08-05T07:00:19.471493Z","iopub.status.idle":"2026-08-05T07:00:19.687994Z","shell.execute_reply.started":"2026-08-05T07:00:19.471454Z","shell.execute_reply":"2026-08-05T07:00:19.686891Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import torch\nprint(torch.cuda.get_device_name(0))\nx = torch.randn(8, 3, 64, 64, device=\"cuda\"); print(\"gpu ok:\", float((x*2).sum()))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-05T07:00:58.290411Z","iopub.execute_input":"2026-08-05T07:00:58.290824Z","iopub.status.idle":"2026-08-05T07:01:02.449057Z","shell.execute_reply.started":"2026-08-05T07:00:58.290791Z","shell.execute_reply":"2026-08-05T07:01:02.448196Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python prepare_data.py","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-05T07:01:23.112678Z","iopub.execute_input":"2026-08-05T07:01:23.113401Z","iopub.status.idle":"2026-08-05T07:37:21.34163Z","shell.execute_reply.started":"2026-08-05T07:01:23.113367Z","shell.execute_reply":"2026-08-05T07:37:21.340904Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python -u train.py --model resnet50","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-05T07:38:07.047537Z","iopub.execute_input":"2026-08-05T07:38:07.048005Z","iopub.status.idle":"2026-08-05T09:43:24.822907Z","shell.execute_reply.started":"2026-08-05T07:38:07.047969Z","shell.execute_reply":"2026-08-05T09:43:24.822214Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}