{"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":"!pip install /kaggle/input/rsna-2022-whl/{pydicom-2.3.0-py3-none-any.whl,pylibjpeg-1.4.0-py3-none-any.whl,python_gdcm-3.0.15-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl}\n!pip install /kaggle/input/rsna-2022-whl/{torch-1.12.1-cp37-cp37m-manylinux1_x86_64.whl,torchvision-0.13.1-cp37-cp37m-manylinux1_x86_64.whl}","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-11-05T15:22:26.558388Z","iopub.execute_input":"2022-11-05T15:22:26.558683Z","iopub.status.idle":"2022-11-05T15:24:19.600893Z","shell.execute_reply.started":"2022-11-05T15:22:26.558615Z","shell.execute_reply":"2022-11-05T15:24:19.599637Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install /kaggle/input/rsna-weights/timm-0.5.4-py3-none-any.whl\n!pip install /kaggle/input/rsna-weights/tifffile-2022.8.8-py3-none-any.whl\n!pip install /kaggle/input/rsna-weights/einops-0.5.0-py3-none-any.whl\n\n","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:24:19.60336Z","iopub.execute_input":"2022-11-05T15:24:19.604067Z","iopub.status.idle":"2022-11-05T15:25:42.314308Z","shell.execute_reply.started":"2022-11-05T15:24:19.60402Z","shell.execute_reply":"2022-11-05T15:25:42.313153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nos.listdir('/kaggle/input/mmdetection-2-17-offline')\n\n!pip install /kaggle/input/mmdetection-2-17-offline/mmcv_full-1.3.14-cp37-cp37m-linux_x86_64.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/pycocotools-2.0.2-cp37-cp37m-linux_x86_64.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/terminaltables-3.1.0-py3-none-any.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/pytest_runner-5.3.1-py3-none-any.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/mmpycocotools-12.0.3-cp37-cp37m-linux_x86_64.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/terminal-0.4.0-py3-none-any.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/mmdet-2.17.0-py3-none-any.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/addict-2.4.0-py3-none-any.whl --no-deps\n!pip install /kaggle/input/mmdetection-2-17-offline/yapf-0.31.0-py2.py3-none-any.whl --no-deps","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:25:42.316409Z","iopub.execute_input":"2022-11-05T15:25:42.316788Z","iopub.status.idle":"2022-11-05T15:29:03.640411Z","shell.execute_reply.started":"2022-11-05T15:25:42.316748Z","shell.execute_reply":"2022-11-05T15:29:03.63923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import sys\nsys.path.append('/kaggle/input/rsnazoopublic')\n","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:03.643635Z","iopub.execute_input":"2022-11-05T15:29:03.644438Z","iopub.status.idle":"2022-11-05T15:29:03.65006Z","shell.execute_reply.started":"2022-11-05T15:29:03.644402Z","shell.execute_reply":"2022-11-05T15:29:03.649149Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport random\nimport re\nfrom dataclasses import dataclass\nfrom typing import Dict\nfrom typing import List\n\nimport albumentations\nimport cv2\nimport numpy as np\nimport pydicom\nimport tifffile\nimport torch\nimport torch.hub\nfrom albumentations import ReplayCompose\nfrom skimage import measure\nfrom torch.functional import Tensor\nfrom torch.utils.data import Dataset, DataLoader\nfrom tqdm import tqdm","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:03.651346Z","iopub.execute_input":"2022-11-05T15:29:03.652231Z","iopub.status.idle":"2022-11-05T15:29:06.008974Z","shell.execute_reply.started":"2022-11-05T15:29:03.652193Z","shell.execute_reply":"2022-11-05T15:29:06.008053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n@dataclass\nclass BatchSlice:\n    i_from: int\n    i_to: int\n    i_start: int\n\n\ndef get_slices(batch: Tensor, dim=1, window: int = 16, overlap: int = 8) -> List[BatchSlice]:\n    num_imgs = batch.size(dim)\n    if num_imgs <= window:\n        return [BatchSlice(0, num_imgs, 0)]\n    stride = window - overlap\n    result = []\n    current_idx = 0\n    while True:\n        next_idx = current_idx + window\n\n        if next_idx >= num_imgs:\n            current_idx = num_imgs - window\n            offset = overlap // 2 if current_idx > 0 else 0\n            next_idx = num_imgs\n            result.append(BatchSlice(current_idx, next_idx, offset))\n            break\n        else:\n            offset = overlap // 2 if current_idx > 0 else 0\n            result.append(BatchSlice(current_idx, next_idx, offset))\n        current_idx += stride\n    return result","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:06.010582Z","iopub.execute_input":"2022-11-05T15:29:06.011217Z","iopub.status.idle":"2022-11-05T15:29:06.022084Z","shell.execute_reply.started":"2022-11-05T15:29:06.01118Z","shell.execute_reply":"2022-11-05T15:29:06.020069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def combine_scan(scan_dir: str, size=512, fix_monochrome: bool = True) -> np.ndarray:\n    num_files = len(os.listdir(scan_dir))\n    images = []\n    offset = 0\n    first = None\n    last = None\n    files = []\n    for i in range(num_files):\n        dpath = os.path.join(scan_dir, f\"{i + offset}.dcm\")\n        if i == 0:\n            while not os.path.exists(dpath):\n                offset += 1\n                dpath = os.path.join(scan_dir, f\"{i + offset}.dcm\")\n        files.append(dpath)\n\n    for dpath in files[::2]:\n        ds = pydicom.dcmread(dpath)\n        if not first:\n            first = ds\n        last = ds\n\n        data = ds.pixel_array\n        data = cv2.resize(data, (size, size))\n        if fix_monochrome and ds.PhotometricInterpretation == \"MONOCHROME1\":\n            data = np.amax(data) - data\n        images.append(data)\n\n    if first and last:\n        if last.ImagePositionPatient[2] > first.ImagePositionPatient[2]:\n            images = images[::-1]\n    return np.array(images)\n\nclass DatasetSeg(Dataset):\n    def __init__(\n            self,\n            dataset_dir: str,\n            cases: List[str],\n    ):\n        self.dataset_dir = dataset_dir\n        self.cases = cases\n\n    def __getitem__(self, i):\n        cube_id = self.cases[i]\n        image_cube = combine_scan(os.path.join(self.dataset_dir, cube_id), size=256)\n        image_mean = image_cube.mean()\n        image_std = image_cube.std()\n        h = image_cube.shape[0]\n\n        images = image_cube\n        if h % 32 > 0:\n            tmp = np.zeros(((h // 32 + 1) * 32, 256, 256))\n            tmp[:h] = images\n            images = tmp\n        images = (images - image_mean) / image_std\n        images = np.expand_dims(images, 0)\n        sample = {}\n        sample['image'] = torch.from_numpy(images).float()\n        sample['cube_id'] = cube_id\n        sample['h'] = h\n        return sample\n\n    def __len__(self):\n        return len(self.cases)\n\n\ncrop_augs =  albumentations.ReplayCompose([\n            albumentations.LongestMaxSize(256),\n            albumentations.PadIfNeeded(256, 256, border_mode=cv2.BORDER_CONSTANT),\n        ])\n\nclass DatasetCrops(Dataset):\n    def __init__(\n            self,\n            dataset_dir: str,\n            cases: List[str],\n            transforms=crop_augs,\n            slice_size=40,\n    ):\n        self.dataset_dir = dataset_dir\n        self.transforms = transforms\n        self.slice_size = slice_size\n        self.cases = cases\n\n    def __getitem__(self, i):\n        cube_id = self.cases[i]\n        mask_cube = tifffile.imread(os.path.join(\"seg_preds\", f\"{cube_id}.tif\"))\n        image_cube = combine_scan(os.path.join(self.dataset_dir, cube_id) ,size=512)\n        boxes = {}\n        for rprop in measure.regionprops(mask_cube):\n            boxes[rprop.label] = rprop.bbox, rprop.area\n\n        image_mean = image_cube.mean()\n        image_std = image_cube.std()\n        slice_size = self.slice_size\n        all_images = []\n        labels = np.zeros((8,))\n        for li in range(1, 8):\n            if li not in boxes:\n                all_images.append(np.zeros((3, self.slice_size, 256, 256)))\n            else:\n                bbox, area = boxes[li]\n                z1, z2 = bbox[0], bbox[3]\n                y1, y2 = max(bbox[1] - 16, 0), min(bbox[4] + 16, 256)\n                x1, x2 = max(bbox[2] - 16, 0), min(bbox[5] + 16, 256)\n                # if z2 - z1 < slice_size:\n                #     z1 = random.randint(max(z2 - slice_size, 0), z1)\n                #     z2 = z1 + slice_size\n                # todo: verify\n                if z2 - z1 < slice_size:\n                    diff = (slice_size - z2 + z1) // 2\n                    z1 = max(0, z1 - diff)\n                    z2 = z1 + slice_size\n                images = image_cube[z1:z2, y1 * 2:y2 * 2, x1 * 2:x2 * 2].copy()\n                masks = mask_cube[z1:z2, y1:y2, x1:x2].copy()\n                slice_size = self.slice_size\n\n                replay = None\n                image_crops = []\n                mask_crops = []\n                for i in range(images.shape[0]):\n                    image = images[i]\n                    mask = masks[i]\n                    h, w, = mask.shape\n                    mask = cv2.resize(mask, (w * 2, h * 2), interpolation=cv2.INTER_NEAREST)\n                    if replay is None:\n                        sample = self.transforms(image=image, mask=mask)\n                        replay = sample[\"replay\"]\n                    else:\n                        sample = ReplayCompose.replay(replay, image=image, mask=mask)\n                    image_ = sample[\"image\"]\n                    image_crops.append(image_)\n                    mask_crops.append(sample[\"mask\"])\n                images = np.array(image_crops).astype(np.float32)\n                masks = np.array(mask_crops).astype(np.float32)\n                images = np.expand_dims(images, -1)\n                masks = np.expand_dims(masks, -1)\n                images = (images - image_mean) / image_std\n\n                images = np.concatenate([images, images, masks], axis=-1)\n                h = images.shape[0]\n                if h > slice_size:\n                    images = images[: slice_size]\n                    all_images.append(np.moveaxis(images, -1, 0))\n                    images = images[-slice_size:]\n                    all_images.append(np.moveaxis(images, -1, 0))\n                else:\n                    if h != slice_size:\n                        tmp = np.zeros((slice_size, *images.shape[1:]))\n                        tmp[:h] = images\n                        images = tmp\n                    all_images.append(np.moveaxis(images, -1, 0))\n\n        sample = {}\n        sample['image'] = torch.from_numpy(np.array(all_images)).float()\n        sample['label'] = torch.from_numpy(labels).float()\n        sample['cube_id'] = cube_id\n        return sample\n\n    def __len__(self):\n        return len(self.cases)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:06.023638Z","iopub.execute_input":"2022-11-05T15:29:06.024209Z","iopub.status.idle":"2022-11-05T15:29:06.055726Z","shell.execute_reply.started":"2022-11-05T15:29:06.024174Z","shell.execute_reply":"2022-11-05T15:29:06.054776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ndef load_checkpoint(model, checkpoint_path, strict=False, verbose=True):\n    if verbose:\n        print(\"=> loading checkpoint '{}'\".format(checkpoint_path))\n    checkpoint = torch.load(checkpoint_path, map_location='cpu')\n    if 'state_dict' in checkpoint:\n        state_dict = checkpoint['state_dict']\n        state_dict = {re.sub(\"^module.\", \"\", k): w for k, w in state_dict.items()}\n        orig_state_dict = model.state_dict()\n        mismatched_keys = []\n        for k, v in state_dict.items():\n            ori_size = orig_state_dict[k].size() if k in orig_state_dict else None\n            if v.size() != ori_size:\n                if verbose:\n                    print(\"SKIPPING!!! Shape of {} changed from {} to {}\".format(k, v.size(), ori_size))\n                mismatched_keys.append(k)\n        for k in mismatched_keys:\n            del state_dict[k]\n        model.load_state_dict(state_dict, strict=strict)\n        del state_dict\n        del orig_state_dict\n        print(\"=> loaded checkpoint '{}' (epoch {})\"\n              .format(checkpoint_path, checkpoint['epoch']))\n    else:\n        model.load_state_dict(checkpoint)\n    del checkpoint\n\n\ndef load_model(conf: Dict, checkpoint: str):\n    model = conf[\"network\"](**conf[\"encoder_params\"])\n    model = model.cuda()\n    load_checkpoint(model, checkpoint)\n    return model.eval()","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:06.0589Z","iopub.execute_input":"2022-11-05T15:29:06.059658Z","iopub.status.idle":"2022-11-05T15:29:06.070708Z","shell.execute_reply.started":"2022-11-05T15:29:06.059623Z","shell.execute_reply":"2022-11-05T15:29:06.069551Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def process_segmentations(models: List[torch.nn.Module], test_dataset_dir: str, out_dir: str,  cases: List[str]):\n    os.makedirs(out_dir, exist_ok=True)\n\n    test_dataset = DatasetSeg(dataset_dir=test_dataset_dir, cases=cases)\n    sampler = None\n    oof_loader = DataLoader(\n        test_dataset, batch_size=1, sampler=sampler, shuffle=False, num_workers=1, pin_memory=False\n    )\n    pred_dir = out_dir\n    os.makedirs(pred_dir, exist_ok=True)\n    for sample in tqdm(oof_loader):\n        image = sample[\"image\"]\n        h = int(sample[\"h\"][0])\n        cube_id = sample[\"cube_id\"][0]\n        imgs = image.cpu().float()\n        case_preds = np.zeros((imgs.shape[2], 256, 256), dtype=np.float32)\n\n        with torch.no_grad():\n            slices = get_slices(imgs, dim=2, window=256, overlap=128)\n            for slice in slices:\n                batch = imgs[:, :, slice.i_from:slice.i_to].cuda().float()\n                with torch.cuda.amp.autocast(enabled=True):\n                    preds = None\n                    for model in models:\n                        if preds is None:\n                            preds = torch.softmax(model(batch)[\"mask\"], dim=1)[0]\n                        else:\n                            preds += torch.softmax(model(batch)[\"mask\"], dim=1)[0]\n                    preds = torch.argmax(preds, dim=0)\n                preds = preds.cpu().numpy()\n\n                for pred_idx in range(slice.i_start, preds.shape[0]):\n                    idx = slice.i_from + pred_idx\n                    y_pred = preds[pred_idx]\n                    case_preds[idx] = y_pred[:, :]\n                torch.cuda.empty_cache()\n        case_preds = np.array(case_preds)[:h]\n        case_preds = case_preds.astype(np.uint8)\n        tifffile.imwrite(os.path.join(pred_dir, f\"{cube_id}.tif\"), case_preds)\n","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:06.072247Z","iopub.execute_input":"2022-11-05T15:29:06.072598Z","iopub.status.idle":"2022-11-05T15:29:06.086692Z","shell.execute_reply.started":"2022-11-05T15:29:06.072565Z","shell.execute_reply":"2022-11-05T15:29:06.085761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from torch import nn\ndef predict_classification(models: List[nn.Module], test_dataset_dir: str, cases: List, output_list: List):\n    test_dataset = DatasetCrops(dataset_dir=test_dataset_dir, cases=cases)\n    dataloader = DataLoader(\n        test_dataset, batch_size=1, sampler=None, shuffle=False, num_workers=1, pin_memory=False\n    )\n    \n    def predict_model(model):\n        preds = []\n        with torch.no_grad():\n            for i in range(len(imgs)):\n                with torch.cuda.amp.autocast():\n                    output = model(imgs[i:i + 1])[\"cls\"][0]\n                pred_slice = torch.sigmoid(output.float()).cpu().numpy().astype(np.float32)\n                with torch.cuda.amp.autocast():\n                    output = model(torch.flip(imgs[i:i + 1], dims=(-1,)))[\"cls\"][0]\n                pred_slice += torch.sigmoid(output.float()).cpu().numpy().astype(np.float32)\n                pred_slice /= 2\n                preds.append(pred_slice)\n        preds = np.max(np.array(preds), axis=0)\n        preds[np.isnan(preds)] = 0.01\n        return preds\n        \n    for sample in tqdm(dataloader):\n        imgs = sample[\"image\"].cuda().float()[0]\n        cube_id = sample[\"cube_id\"][0]\n        with torch.no_grad():\n            preds = []\n            for model in models:\n                preds.append(predict_model(model))\n            preds = np.average(np.array(preds), axis=0)\n            preds = np.clip(preds, 0.01, 0.99)\n            output_list.append([cube_id, preds])","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:06.090781Z","iopub.execute_input":"2022-11-05T15:29:06.091041Z","iopub.status.idle":"2022-11-05T15:29:06.10463Z","shell.execute_reply.started":"2022-11-05T15:29:06.091018Z","shell.execute_reply":"2022-11-05T15:29:06.103515Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import zoo\nconfig_seg  = {\n  \"network\": zoo.ResNet3dCSN2P1D,\n  \"encoder_params\": {\n    \"encoder\": \"r50ir\"\n  }\n}\ntest_dataset_dir = \"/kaggle/input/rsna-2022-cervical-spine-fracture-detection/test_images/\"\ncases = os.listdir(test_dataset_dir)\nseg_model = load_model(config_seg, \"/kaggle/input/rsna-weights/256_ResNet3dCSN2P1D_r50ir_0_dice\")\nds = DatasetSeg(test_dataset_dir, cases)\n","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:06.106833Z","iopub.execute_input":"2022-11-05T15:29:06.10869Z","iopub.status.idle":"2022-11-05T15:29:19.682461Z","shell.execute_reply.started":"2022-11-05T15:29:06.108639Z","shell.execute_reply":"2022-11-05T15:29:19.681184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_dir = \"/kaggle/working/seg_preds\"\nprocess_segmentations([seg_model], test_dataset_dir,out_dir=preds_dir, cases=cases )","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:19.684358Z","iopub.execute_input":"2022-11-05T15:29:19.684748Z","iopub.status.idle":"2022-11-05T15:29:33.081479Z","shell.execute_reply.started":"2022-11-05T15:29:19.684706Z","shell.execute_reply":"2022-11-05T15:29:33.080451Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"config_cls = {\n  \"network\": zoo.ClassifierResNet3dCSN2P1D,\n  \"encoder_params\": {\n    \"encoder\": \"r152ir\",\n    \"num_classes\": 8,\n    \"pool\": \"max\"\n  }\n}\ncls_models = [\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_5_best_full_ClassifierResNet3dCSN2P1D_r152ir_0.pth\"),\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_5_best_full_ClassifierResNet3dCSN2P1D_r152ir_1.pth\"),\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_5_best_full_ClassifierResNet3dCSN2P1D_r152ir_2.pth\"),\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_5_best_full_ClassifierResNet3dCSN2P1D_r152ir_3.pth\"),\n\n]\n\nconfig_cls = {\n  \"network\": zoo.ClassifierResNet3dCSN2P1D,\n  \"encoder_params\": {\n    \"encoder\": \"r152ip\",\n    \"num_classes\": 8,\n    \"pool\": \"max\"\n  }\n}\n\ncls_models += [\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_3_best_full_frozen_ClassifierResNet3dCSN2P1D_r152ip_0.pth\"),\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_3_best_full_frozen_ClassifierResNet3dCSN2P1D_r152ip_1.pth\"),\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_3_best_full_frozen_ClassifierResNet3dCSN2P1D_r152ip_2.pth\"),\n    load_model(config_cls, \"/kaggle/input/rsna-weights/swa_3_best_full_frozen_ClassifierResNet3dCSN2P1D_r152ip_3.pth\"),\n\n]","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:33.085697Z","iopub.execute_input":"2022-11-05T15:29:33.088449Z","iopub.status.idle":"2022-11-05T15:29:57.618835Z","shell.execute_reply.started":"2022-11-05T15:29:33.088407Z","shell.execute_reply":"2022-11-05T15:29:57.617716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"output = []\n\npredict_classification(cls_models, test_dataset_dir, cases, output)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:29:57.620559Z","iopub.execute_input":"2022-11-05T15:29:57.620928Z","iopub.status.idle":"2022-11-05T15:30:32.983803Z","shell.execute_reply.started":"2022-11-05T15:29:57.620891Z","shell.execute_reply":"2022-11-05T15:30:32.98221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nsub_df = pd.read_csv('/kaggle/input/rsna-2022-cervical-spine-fracture-detection/test.csv')\n\ndel sub_df['prediction_type']\ndel sub_df['StudyInstanceUID']\n\ndata = []\nfor cube_id, preds in output:\n    data.append([f\"{cube_id}_patient_overall\", preds[0]])\n    for i in range(1, 8):\n        data.append([f\"{cube_id}_C{i}\", preds[i]])\npred_df = pd.DataFrame(data, columns=[\"row_id\", \"fractured\"])\nsub_df = sub_df.merge(pred_df, on=['row_id'])\nsub_df.to_csv('submission.csv',index=False)\nsub_df.head(50)","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:30:32.985672Z","iopub.execute_input":"2022-11-05T15:30:32.986397Z","iopub.status.idle":"2022-11-05T15:30:33.052716Z","shell.execute_reply.started":"2022-11-05T15:30:32.986353Z","shell.execute_reply":"2022-11-05T15:30:33.051636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import shutil\nshutil.rmtree('/kaggle/working/seg_preds')","metadata":{"execution":{"iopub.status.busy":"2022-11-05T15:30:33.054295Z","iopub.execute_input":"2022-11-05T15:30:33.054659Z","iopub.status.idle":"2022-11-05T15:30:33.067505Z","shell.execute_reply.started":"2022-11-05T15:30:33.054622Z","shell.execute_reply":"2022-11-05T15:30:33.06666Z"},"trusted":true},"execution_count":null,"outputs":[]}]}