{"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":"from fastcore.all import *\nfrom fastai.vision.all import *\nimport pandas as pd\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-17T06:10:46.248733Z","iopub.execute_input":"2022-08-17T06:10:46.249321Z","iopub.status.idle":"2022-08-17T06:10:46.259981Z","shell.execute_reply.started":"2022-08-17T06:10:46.249277Z","shell.execute_reply":"2022-08-17T06:10:46.258917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = Path('../input/rsna-csfd-256x256-jpg-dataset/train_images')\ndf = pd.read_csv('../input/rsna-2022-cervical-spine-fracture-detection/train.csv')\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-17T06:10:47.926089Z","iopub.execute_input":"2022-08-17T06:10:47.926505Z","iopub.status.idle":"2022-08-17T06:10:47.958284Z","shell.execute_reply.started":"2022-08-17T06:10:47.926473Z","shell.execute_reply":"2022-08-17T06:10:47.95689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_x(r): return path/r['StudyInstanceUID']/os.listdir(path/r['StudyInstanceUID'])[0]\ndef get_y(r): return r['patient_overall']","metadata":{"execution":{"iopub.status.busy":"2022-08-17T06:10:50.79583Z","iopub.execute_input":"2022-08-17T06:10:50.796798Z","iopub.status.idle":"2022-08-17T06:10:50.804766Z","shell.execute_reply.started":"2022-08-17T06:10:50.796747Z","shell.execute_reply":"2022-08-17T06:10:50.803199Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dblock = DataBlock(blocks=(ImageBlock, CategoryBlock),\n                   splitter=RandomSplitter(valid_pct=0.2, seed=42),\n                   get_x=get_x, \n                   get_y=get_y)\ndls = dblock.dataloaders(df)","metadata":{"execution":{"iopub.status.busy":"2022-08-17T06:10:52.936389Z","iopub.execute_input":"2022-08-17T06:10:52.937325Z","iopub.status.idle":"2022-08-17T06:10:53.401728Z","shell.execute_reply.started":"2022-08-17T06:10:52.937269Z","shell.execute_reply":"2022-08-17T06:10:53.3995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dls.show_batch(max_n=3)","metadata":{"execution":{"iopub.status.busy":"2022-08-17T06:11:07.274755Z","iopub.execute_input":"2022-08-17T06:11:07.275218Z","iopub.status.idle":"2022-08-17T06:11:07.976796Z","shell.execute_reply.started":"2022-08-17T06:11:07.275178Z","shell.execute_reply":"2022-08-17T06:11:07.975473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn = vision_learner(dls, resnet18, metrics=error_rate)\nlearn.fine_tune(1)","metadata":{"execution":{"iopub.status.busy":"2022-08-17T06:24:26.416901Z","iopub.execute_input":"2022-08-17T06:24:26.417495Z","iopub.status.idle":"2022-08-17T06:33:37.004661Z","shell.execute_reply.started":"2022-08-17T06:24:26.417449Z","shell.execute_reply":"2022-08-17T06:33:37.002919Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.lr_find()","metadata":{"execution":{"iopub.status.busy":"2022-08-17T06:56:34.171164Z","iopub.execute_input":"2022-08-17T06:56:34.171739Z","iopub.status.idle":"2022-08-17T07:13:39.10968Z","shell.execute_reply.started":"2022-08-17T06:56:34.171694Z","shell.execute_reply":"2022-08-17T07:13:39.108127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(3, lr_max=slice(1e-4, 1e-3)) ","metadata":{"execution":{"iopub.status.busy":"2022-08-17T07:41:42.382979Z","iopub.execute_input":"2022-08-17T07:41:42.385225Z","iopub.status.idle":"2022-08-17T07:56:56.800557Z","shell.execute_reply.started":"2022-08-17T07:41:42.385138Z","shell.execute_reply":"2022-08-17T07:56:56.798882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.lr_find()","metadata":{"execution":{"iopub.status.busy":"2022-08-17T08:14:09.080414Z","iopub.execute_input":"2022-08-17T08:14:09.081055Z","iopub.status.idle":"2022-08-17T08:25:26.520785Z","shell.execute_reply.started":"2022-08-17T08:14:09.080993Z","shell.execute_reply":"2022-08-17T08:25:26.519285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(3, lr_max=slice(1e-4, 1e-3))","metadata":{"execution":{"iopub.status.busy":"2022-08-17T08:33:12.975869Z","iopub.execute_input":"2022-08-17T08:33:12.976427Z","iopub.status.idle":"2022-08-17T08:48:21.898151Z","shell.execute_reply.started":"2022-08-17T08:33:12.976378Z","shell.execute_reply":"2022-08-17T08:48:21.896295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}