{"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":"gpu","dataSources":[{"sourceId":71549,"databundleVersionId":8561470,"isSourceIdPinned":false,"sourceType":"competition"}],"dockerImageVersionId":31193,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!git clone https://github.com/rangha26/ML_nhom7.git\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-12-15T16:32:45.077346Z","iopub.execute_input":"2025-12-15T16:32:45.077604Z","iopub.status.idle":"2025-12-15T16:32:45.596982Z","shell.execute_reply.started":"2025-12-15T16:32:45.077578Z","shell.execute_reply":"2025-12-15T16:32:45.596297Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%cd /kaggle/working/ML_nhom7\n!ls\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-15T16:32:45.597899Z","iopub.execute_input":"2025-12-15T16:32:45.598112Z","iopub.status.idle":"2025-12-15T16:32:45.715768Z","shell.execute_reply.started":"2025-12-15T16:32:45.598089Z","shell.execute_reply":"2025-12-15T16:32:45.715111Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install -r requirements.txt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-15T16:32:45.717329Z","iopub.execute_input":"2025-12-15T16:32:45.718009Z","iopub.status.idle":"2025-12-15T16:32:49.137618Z","shell.execute_reply.started":"2025-12-15T16:32:45.717980Z","shell.execute_reply":"2025-12-15T16:32:49.136905Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%%bash\ncd /kaggle/working/RSNA2024\n\nCLEARML_OFFLINE_MODE=1 TMPDIR=/dev/shm python - << 'PY'\nimport sys, os\nsys.path.insert(0, \".\")\n\nsys.argv = [\n    \"train.py\",\n    \"--data_dir\", \"/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification\",\n    \"--workdir\", \"/kaggle/working/workdir\",\n    \"--epochs\", \"20\", \n    \"--batch_size\", \"2\",\n    \"--accumulation_steps\", \"2\",\n    \"--num_workers\", \"0\",\n]\n\n# patch pandas.read_csv để chỉ lấy ít dòng -> giảm dataset -> giảm cache output\nimport pandas as pd\n_real_read_csv = pd.read_csv\ndef _patched_read_csv(path, *args, **kwargs):\n    df = _real_read_csv(path, *args, **kwargs)\n    if str(path).endswith(\"train.csv\"):\n        df = df.sample(n=min(300, len(df)), random_state=42).reset_index(drop=True)  # <= đổi 300 thành 100/200 nếu muốn nhẹ hơn\n    return df\npd.read_csv = _patched_read_csv\n\nimport config\nconfig.args.num_workers = int(config.args.num_workers)\nconfig.args.batch_size = int(config.args.batch_size)\nconfig.args.epochs = int(config.args.epochs)\nconfig.args.accumulation_steps = int(config.args.accumulation_steps)\n\nconfig.args.image_size = (32, 128, 256)\n\n# đưa cache sang RAM để không ăn /kaggle/working\nconfig.args.cache_dir = \"/dev/shm/rsna_cache\"\n\nimport runpy\nrunpy.run_path(\"train.py\", run_name=\"__main__\")\nPY","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-15T16:32:49.138718Z","iopub.execute_input":"2025-12-15T16:32:49.139029Z","iopub.status.idle":"2025-12-15T16:58:55.514604Z","shell.execute_reply.started":"2025-12-15T16:32:49.138980Z","shell.execute_reply":"2025-12-15T16:58:55.513847Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!cp \"/kaggle/working/workdir/SEResNext101_custom_[no_resample]_[augs1]_32x128x256/model_best.pth\" \\\n    \"/kaggle/working/model_best.pth\"\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-15T16:58:55.515447Z","iopub.execute_input":"2025-12-15T16:58:55.515716Z","iopub.status.idle":"2025-12-15T16:58:55.790024Z","shell.execute_reply.started":"2025-12-15T16:58:55.515697Z","shell.execute_reply":"2025-12-15T16:58:55.789261Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls -lh /kaggle/working/model_best.pth\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-15T16:58:55.790988Z","iopub.execute_input":"2025-12-15T16:58:55.791325Z","iopub.status.idle":"2025-12-15T16:58:55.908793Z","shell.execute_reply.started":"2025-12-15T16:58:55.791299Z","shell.execute_reply":"2025-12-15T16:58:55.907958Z"}},"outputs":[],"execution_count":null}]}