{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-12-12T11:53:43.228291Z","iopub.execute_input":"2022-12-12T11:53:43.228812Z","iopub.status.idle":"2022-12-12T11:53:43.261246Z","shell.execute_reply.started":"2022-12-12T11:53:43.228714Z","shell.execute_reply":"2022-12-12T11:53:43.260393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from fastai.data.all import *\nfrom fastai.vision.all import *\n\npath = '../input/rsna-mammography-images-as-pngs/images_as_pngs/train_images_processed'\n\ntrain_csv = pd.read_csv('../input/rsna-breast-cancer-detection/train.csv')\nfn2label = {fn: cancer_or_not for fn, cancer_or_not in zip(train_csv['image_id'].astype('str'), train_csv['cancer'])}\n\ndef label_func(path):\n    return fn2label[path.stem]\n\ndblock = DataBlock(\n    blocks    = (ImageBlock, CategoryBlock),\n    get_items = get_image_files,\n    get_y = label_func,\n    splitter  = RandomSplitter()\n)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T11:53:43.264809Z","iopub.execute_input":"2022-12-12T11:53:43.265436Z","iopub.status.idle":"2022-12-12T11:53:46.107622Z","shell.execute_reply.started":"2022-12-12T11:53:43.265403Z","shell.execute_reply":"2022-12-12T11:53:46.106625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dsets = dblock.datasets(path)\ndls = dblock.dataloaders(path)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-12T11:53:46.1089Z","iopub.execute_input":"2022-12-12T11:53:46.109237Z","iopub.status.idle":"2022-12-12T11:54:46.708211Z","shell.execute_reply.started":"2022-12-12T11:53:46.109204Z","shell.execute_reply":"2022-12-12T11:54:46.707156Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dls.show_batch()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T11:54:46.710615Z","iopub.execute_input":"2022-12-12T11:54:46.711281Z","iopub.status.idle":"2022-12-12T11:54:48.179236Z","shell.execute_reply.started":"2022-12-12T11:54:46.711245Z","shell.execute_reply":"2022-12-12T11:54:48.178282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn = vision_learner(dls, resnet18, metrics=error_rate, pretrained=True)\nlearn.fit_one_cycle(8, 1e-2)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T12:23:49.069673Z","iopub.execute_input":"2022-12-12T12:23:49.070039Z","iopub.status.idle":"2022-12-12T12:42:25.83195Z","shell.execute_reply.started":"2022-12-12T12:23:49.070009Z","shell.execute_reply":"2022-12-12T12:42:25.830893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv(\"/kaggle/input/rsna-breast-cancer-detection/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-12-12T12:59:41.523928Z","iopub.execute_input":"2022-12-12T12:59:41.524292Z","iopub.status.idle":"2022-12-12T12:59:41.543403Z","shell.execute_reply.started":"2022-12-12T12:59:41.524253Z","shell.execute_reply":"2022-12-12T12:59:41.542564Z"},"trusted":true},"execution_count":null,"outputs":[]}]}