{"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":"markdown","source":"# **Import Libraries**","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom PIL import Image\nimport tifffile as tiff\nimport os\nimport gc\nfrom tqdm.notebook import tqdm\nimport rasterio\nfrom rasterio.windows import Window\n\nfrom fastai.vision.all import *\nfrom torch.utils.data import Dataset, DataLoader\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\nimport time\nimport matplotlib.pyplot as plt\nimport cv2\nimport glob\nimport os\nimport shutil\nimport random\nimport torch\nimport torch.nn as nn\nfrom torch.cuda import amp\nimport albumentations as A\nimport multiprocessing as mp\nimport copy\nfrom collections import defaultdict\nimport gc\nfrom tqdm import tqdm\nimport tifffile\nfrom colorama import Fore, Back, Style","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":3.066435,"end_time":"2021-03-12T06:33:17.956368","exception":false,"start_time":"2021-03-12T06:33:14.889933","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-11T06:07:16.336514Z","iopub.execute_input":"2022-08-11T06:07:16.337730Z","iopub.status.idle":"2022-08-11T06:07:20.742497Z","shell.execute_reply.started":"2022-08-11T06:07:16.337590Z","shell.execute_reply":"2022-08-11T06:07:20.741515Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Config**","metadata":{}},{"cell_type":"code","source":"class CFG:\n    seed = 0\n    batch_size = 1\n    head = \"UNet\"\n    backbone = \"efficientnet-b7\" #['efficientnet-b0', efficientnet-b1', ... , efficientnet-b7']\n    device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n    base_path = '../input/hubmap-organ-segmentation'\n    num_workers = 2\n    num_classes = 1\n    n_accumulate = max(1, 16//batch_size)\n    loss = 'Dice'\n    weight_decay = 1e-6\n    ckpt_paths = [f'../input/eff-aspp/efficientnet-b7_best_epoch-00.pth'] # '../hist_weight/unet/last_epoch-00.pth'\n    thr = 0.225","metadata":{"execution":{"iopub.status.busy":"2022-08-11T06:07:20.744650Z","iopub.execute_input":"2022-08-11T06:07:20.745287Z","iopub.status.idle":"2022-08-11T06:07:20.754154Z","shell.execute_reply.started":"2022-08-11T06:07:20.745246Z","shell.execute_reply":"2022-08-11T06:07:20.751579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DATA = '../input/hubmap-organ-segmentation/test_images/'\ndf_sample = pd.read_csv('../input/hubmap-organ-segmentation/test.csv')\nbs = CFG.batch_size\ndevice = CFG.device","metadata":{"papermill":{"duration":0.024698,"end_time":"2021-03-12T06:33:17.991398","exception":false,"start_time":"2021-03-12T06:33:17.9667","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-11T06:07:20.755762Z","iopub.execute_input":"2022-08-11T06:07:20.756426Z","iopub.status.idle":"2022-08-11T06:07:20.800736Z","shell.execute_reply.started":"2022-08-11T06:07:20.756389Z","shell.execute_reply":"2022-08-11T06:07:20.799695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Helper Functions**","metadata":{}},{"cell_type":"code","source":"def rle_encode_less_memory(img):\n    #the image should be transposed\n    pixels = img.T.flatten()\n    # This simplified method requires first and last pixel to be zero\n    pixels[0] = 0\n    pixels[-1] = 0\n    runs = np.where(pixels[1:] != pixels[:-1])[0] + 2\n    runs[1::2] -= runs[::2]\n    return ' '.join(str(x) for x in runs)","metadata":{"_kg_hide-input":true,"papermill":{"duration":0.026676,"end_time":"2021-03-12T06:33:18.043775","exception":false,"start_time":"2021-03-12T06:33:18.017099","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-11T06:07:20.802780Z","iopub.execute_input":"2022-08-11T06:07:20.804122Z","iopub.status.idle":"2022-08-11T06:07:20.811535Z","shell.execute_reply.started":"2022-08-11T06:07:20.804084Z","shell.execute_reply":"2022-08-11T06:07:20.810231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mean = np.array([0.7720342, 0.74582646, 0.76392896])\nstd = np.array([0.24745085, 0.26182273, 0.25782376])\n\n\ndef img2tensor(img,dtype:np.dtype=np.float32):\n    if img.ndim==2 : img = np.expand_dims(img,2)\n    img = np.transpose(img,(2,0,1))\n    return torch.from_numpy(img.astype(dtype, copy=False))\n\n    \nclass HuBMAPDataset(Dataset):\n    def __init__(self,df,tfms = None):\n        super(HuBMAPDataset,self).__init__()\n        self.df = df\n        self.tfms = tfms\n        \n    def __len__(self):\n        return len(self.df)\n    \n    def __getitem__(self,idx):\n        fname = self.df['id'][idx]\n        img = cv2.cvtColor(cv2.imread(os.path.join(DATA,f\"{fname}.tiff\")), cv2.COLOR_BGR2RGB)\n        height,width = self.df['img_height'][idx],self.df['img_width'][idx]\n        organ = self.df['organ'][idx]\n        if self.tfms:\n            img = self.tfms(image = img)['image']\n        img = (img/255.0-mean)/std\n        return torch.tensor(img).permute(2,0,1).to(torch.float32), organ, fname, height, width","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-08-11T06:07:20.813352Z","iopub.execute_input":"2022-08-11T06:07:20.814239Z","iopub.status.idle":"2022-08-11T06:07:20.826318Z","shell.execute_reply.started":"2022-08-11T06:07:20.814198Z","shell.execute_reply":"2022-08-11T06:07:20.825211Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Dataset**","metadata":{"papermill":{"duration":0.008314,"end_time":"2021-03-12T06:33:18.008555","exception":false,"start_time":"2021-03-12T06:33:18.000241","status":"completed"},"tags":[]}},{"cell_type":"code","source":"def get_transforms(*, data):\n    if data == 'train':\n        return A.Compose([\n            A.Resize(768,768, interpolation=cv2.INTER_NEAREST, p=1.0),\n            A.HorizontalFlip(p=0.5),\n            A.VerticalFlip(),\n            A.RandomRotate90(p=1),\n            #Morphology\n            A.ShiftScaleRotate(shift_limit=0, scale_limit=(-0.2,0.2), rotate_limit=(-30,30), \n                             interpolation=1, border_mode=0, value=(0,0,0), p=0.5),\n            A.GaussNoise(var_limit=(0,50.0), mean=0, p=0.5),\n            A.GaussianBlur(blur_limit=(3,7), p=0.5),\n            #Color\n            A.RandomBrightnessContrast(brightness_limit=0.35, contrast_limit=0.5, \n                                     brightness_by_max=True,p=0.5),\n            A.HueSaturationValue(hue_shift_limit=30, sat_shift_limit=30, \n                               val_shift_limit=0, p=0.5),\n            A.OneOf([\n                A.OpticalDistortion(p=0.3),\n                A.GridDistortion(p=.1),\n                A.IAAPiecewiseAffine(p=0.3),\n            ], p=0.3),\n        ])\n\n    elif data == 'valid':\n        return A.Compose([\n            A.Resize(768,768, interpolation=cv2.INTER_NEAREST, p=1.0),\n        ])","metadata":{"papermill":{"duration":0.037945,"end_time":"2021-03-12T06:33:18.090462","exception":false,"start_time":"2021-03-12T06:33:18.052517","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-11T06:07:20.827516Z","iopub.execute_input":"2022-08-11T06:07:20.829187Z","iopub.status.idle":"2022-08-11T06:07:20.841431Z","shell.execute_reply.started":"2022-08-11T06:07:20.829150Z","shell.execute_reply":"2022-08-11T06:07:20.840319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def Model_inference(models,dl, tta=False):\n    result = []\n    organs = []\n    tk0 = tqdm(enumerate(dl), total=len(dl))\n    for i, (images,organ,idx,height,width) in tk0:\n        images = images.to(device)\n        py = None\n        for model in models:\n            p = model(images)\n            p = torch.sigmoid(p).detach()\n            if py is None: py = p\n            else: py += p\n        if tta:\n            flips = [[-1],[-2],[-2,-1]]\n            for f in flips:\n                xf = torch.flip(images,f)\n                for model in models:\n                    p = model(xf)\n                    p = torch.flip(p,f)\n                    py += torch.sigmoid(p).detach()\n            py /= (1+len(flips)) \n            \n        py /= len(models)\n        mask = F.interpolate(py, size = (height,width), mode='bilinear', align_corners=False)\n        result.append(mask.cpu().numpy())\n        organs.append(organ)\n    return result,organs","metadata":{"papermill":{"duration":0.030274,"end_time":"2021-03-12T06:33:18.129546","exception":false,"start_time":"2021-03-12T06:33:18.099272","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-11T06:07:20.843365Z","iopub.execute_input":"2022-08-11T06:07:20.844117Z","iopub.status.idle":"2022-08-11T06:07:20.856357Z","shell.execute_reply.started":"2022-08-11T06:07:20.844073Z","shell.execute_reply":"2022-08-11T06:07:20.855276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Model","metadata":{"papermill":{"duration":0.008902,"end_time":"2021-03-12T06:33:18.153045","exception":false,"start_time":"2021-03-12T06:33:18.144143","status":"completed"},"tags":[]}},{"cell_type":"code","source":"from fastai.vision.all import *\n\nclass FPN(nn.Module):\n    def __init__(self, input_channels:list, output_channels:list):\n        super().__init__()\n        self.convs = nn.ModuleList(\n            [nn.Sequential(nn.Conv2d(in_ch, out_ch*2, kernel_size=3, padding=1),\n             nn.ReLU(inplace=True), nn.BatchNorm2d(out_ch*2),\n             nn.Conv2d(out_ch*2, out_ch, kernel_size=3, padding=1))\n            for in_ch, out_ch in zip(input_channels, output_channels)])\n\n    def forward(self, xs:list, last_layer):\n        hcs = [F.interpolate(c(x),scale_factor=2**(len(self.convs)-i),mode='bilinear') \n               for i,(c,x) in enumerate(zip(self.convs, xs))]\n        hcs.append(last_layer)\n        return torch.cat(hcs, dim=1)\n\nclass UnetBlock(Module):\n    def __init__(self, up_in_c:int, x_in_c:int, nf:int=None, blur:bool=False,\n                 self_attention:bool=False, **kwargs):\n        super().__init__()\n        self.shuf = PixelShuffle_ICNR(up_in_c, up_in_c//2, blur=blur, **kwargs)\n        self.bn = nn.BatchNorm2d(x_in_c)\n        ni = up_in_c//2 + x_in_c\n        nf = nf if nf is not None else max(up_in_c//2,32)\n        self.conv1 = ConvLayer(ni, nf, norm_type=None, **kwargs)\n        self.conv2 = ConvLayer(nf, nf, norm_type=None,\n            xtra=SelfAttention(nf) if self_attention else None, **kwargs)\n        self.relu = nn.ReLU(inplace=True)\n\n    def forward(self, up_in:Tensor, left_in:Tensor) -> Tensor:\n        s = left_in\n        up_out = self.shuf(up_in)\n        cat_x = self.relu(torch.cat([up_out, self.bn(s)], dim=1))\n        return self.conv2(self.conv1(cat_x))\n\nclass _ASPPModule(nn.Module):\n    def __init__(self, inplanes, planes, kernel_size, padding, dilation, groups=1):\n        super().__init__()\n        self.atrous_conv = nn.Conv2d(inplanes, planes, kernel_size=kernel_size,\n                stride=1, padding=padding, dilation=dilation, bias=False, groups=groups)\n        self.bn = nn.BatchNorm2d(planes)\n        self.relu = nn.ReLU()\n\n        self._init_weight()\n\n    def forward(self, x):\n        x = self.atrous_conv(x)\n        x = self.bn(x)\n\n        return self.relu(x)\n\n    def _init_weight(self):\n        for m in self.modules():\n            if isinstance(m, nn.Conv2d):\n                torch.nn.init.kaiming_normal_(m.weight)\n            elif isinstance(m, nn.BatchNorm2d):\n                m.weight.data.fill_(1)\n                m.bias.data.zero_()\n\nclass ASPP(nn.Module):\n    def __init__(self, inplanes=512, mid_c=256, dilations=[6, 12, 18, 24], out_c=None):\n        super().__init__()\n        self.aspps = [_ASPPModule(inplanes, mid_c, 1, padding=0, dilation=1)] + \\\n            [_ASPPModule(inplanes, mid_c, 3, padding=d, dilation=d,groups=4) for d in dilations]\n        self.aspps = nn.ModuleList(self.aspps)\n        self.global_pool = nn.Sequential(nn.AdaptiveMaxPool2d((1, 1)),\n                        nn.Conv2d(inplanes, mid_c, 1, stride=1, bias=False),\n                        nn.BatchNorm2d(mid_c), nn.ReLU())\n        out_c = out_c if out_c is not None else mid_c\n        self.out_conv = nn.Sequential(nn.Conv2d(mid_c*(2+len(dilations)), out_c, 1, bias=False),\n                                    nn.BatchNorm2d(out_c), nn.ReLU(inplace=True))\n        self.conv1 = nn.Conv2d(mid_c*(2+len(dilations)), out_c, 1, bias=False)\n        self._init_weight()\n\n    def forward(self, x):\n        x0 = self.global_pool(x)\n        xs = [aspp(x) for aspp in self.aspps]\n        x0 = F.interpolate(x0, size=xs[0].size()[2:], mode='bilinear', align_corners=True)\n        x = torch.cat([x0] + xs, dim=1)\n        return self.out_conv(x)\n\n    def _init_weight(self):\n        for m in self.modules():\n            if isinstance(m, nn.Conv2d):\n                torch.nn.init.kaiming_normal_(m.weight)\n            elif isinstance(m, nn.BatchNorm2d):\n                m.weight.data.fill_(1)\n                m.bias.data.zero_()\n\npretrained_root = '../input/my-efficientnet-pytorch/'\nefficient_net_encoders = {\n    \"efficientnet-b0\": {\n        \"out_channels\": (3, 32, 24, 40, 112, 320),\n        \"stage_idxs\": (3, 5, 9, 16),\n        \"weight_path\": pretrained_root + \"efficientnet-b0-08094119.pth\"\n    },\n    \"efficientnet-b1\": {\n        \"out_channels\": (3, 32, 24, 40, 112, 320),\n        \"stage_idxs\": (5, 8, 16, 23),\n        \"weight_path\": pretrained_root + \"efficientnet-b1-dbc7070a.pth\"\n    },\n    \"efficientnet-b2\": {\n        \"out_channels\": (3, 32, 24, 48, 120, 352),\n        \"stage_idxs\": (5, 8, 16, 23),\n        \"weight_path\": pretrained_root + \"efficientnet-b2-27687264.pth\"\n    },\n    \"efficientnet-b3\": {\n        \"out_channels\": (3, 40, 32, 48, 136, 384),\n        \"stage_idxs\": (5, 8, 18, 26),\n        \"weight_path\": pretrained_root + \"efficientnet-b3-c8376fa2.pth\"\n    },\n    \"efficientnet-b4\": {\n        \"out_channels\": (3, 48, 32, 56, 160, 448),\n        \"stage_idxs\": (6, 10, 22, 32),\n        \"weight_path\": pretrained_root + \"efficientnet-b4-e116e8b3.pth\"\n    },\n    \"efficientnet-b5\": {\n        \"out_channels\": (3, 48, 40, 64, 176, 512),\n        \"stage_idxs\": (8, 13, 27, 39),\n        \"weight_path\": pretrained_root + \"efficientnet-b5-586e6cc6.pth\"\n    },\n    \"efficientnet-b6\": {\n        \"out_channels\": (3, 56, 40, 72, 200, 576),\n        \"stage_idxs\": (9, 15, 31, 45),\n        \"weight_path\": pretrained_root + \"efficientnet-b6-c76e70fd.pth\"\n    },\n    \"efficientnet-b7\": {\n        \"out_channels\": (3, 64, 48, 80, 224, 640),\n        \"stage_idxs\": (11, 18, 38, 55),\n        \"weight_path\": pretrained_root + \"efficientnet-b7-dcc49843.pth\"\n    }\n}\n\nimport sys\nsys.path.insert(0, '../input/my-efficientnet-pytorch/EfficientNet-PyTorch/EfficientNet-PyTorch/EfficientNet-PyTorch-master')\n\nfrom efficientnet_pytorch import EfficientNet\nfrom efficientnet_pytorch.utils import url_map, url_map_advprop, get_model_params\n\n\nclass EfficientNetEncoder(EfficientNet):\n    def __init__(self, stage_idxs, out_channels, model_name, depth=5):\n\n        blocks_args, global_params = get_model_params(model_name, override_params=None)\n        super().__init__(blocks_args, global_params)\n\n        cfg = efficient_net_encoders[model_name]\n\n        self._stage_idxs = stage_idxs\n        self._out_channels = out_channels\n        self._depth = depth\n        self._in_channels = 3\n\n        del self._fc\n        self.load_state_dict(torch.load(cfg['weight_path']))\n\n    def get_stages(self):\n        return [\n            nn.Identity(),\n            nn.Sequential(self._conv_stem, self._bn0, self._swish),\n            self._blocks[:self._stage_idxs[0]],\n            self._blocks[self._stage_idxs[0]:self._stage_idxs[1]],\n            self._blocks[self._stage_idxs[1]:self._stage_idxs[2]],\n            self._blocks[self._stage_idxs[2]:],\n        ]\n\n    def forward(self, x):\n        stages = self.get_stages()\n\n        block_number = 0.\n        drop_connect_rate = self._global_params.drop_connect_rate\n\n        features = []\n        for i in range(self._depth + 1):\n\n            # Identity and Sequential stages\n            if i < 2:\n                x = stages[i](x)\n\n            # Block stages need drop_connect rate\n            else:\n                for module in stages[i]:\n                    drop_connect = drop_connect_rate * block_number / len(self._blocks)\n                    block_number += 1.\n                    x = module(x, drop_connect)\n\n            features.append(x)\n\n        return features\n\n    def load_state_dict(self, state_dict, **kwargs):\n        state_dict.pop(\"_fc.bias\")\n        state_dict.pop(\"_fc.weight\")\n        super().load_state_dict(state_dict, **kwargs)  \n\n\nclass EffUnet(nn.Module):\n    def __init__(self, model_name, stride=1):\n        super().__init__()\n\n        cfg = efficient_net_encoders[model_name]\n        stage_idxs = cfg['stage_idxs']\n        out_channels = cfg['out_channels']\n\n        self.encoder = EfficientNetEncoder(stage_idxs, out_channels, model_name)\n\n        #aspp with customized dilatations\n        self.aspp = ASPP(out_channels[-1], 256, out_c=384, \n                         dilations=[stride*1, stride*2, stride*3, stride*4])\n        self.drop_aspp = nn.Dropout2d(0.5)\n        #decoder\n        self.dec4 = UnetBlock(384, out_channels[-2], 256)\n        self.dec3 = UnetBlock(256, out_channels[-3], 128)\n        self.dec2 = UnetBlock(128, out_channels[-4], 64)\n        self.dec1 = UnetBlock(64, out_channels[-5], 32)\n        self.fpn = FPN([384, 256, 128, 64], [16]*4)\n        self.drop = nn.Dropout2d(0.1)\n        self.final_conv = ConvLayer(32+16*4, 1, ks=1, norm_type=None, act_cls=None)\n\n    def forward(self, x):\n        enc0, enc1, enc2, enc3, enc4 = self.encoder(x)[-5:]\n        enc5 = self.aspp(enc4)\n        dec3 = self.dec4(self.drop_aspp(enc5), enc3)\n        dec2 = self.dec3(dec3,enc2)\n        dec1 = self.dec2(dec2,enc1)\n        dec0 = self.dec1(dec1,enc0)\n        x = self.fpn([enc5, dec3, dec2, dec1], dec0)\n        x = self.final_conv(self.drop(x))\n        x = F.interpolate(x,scale_factor=2,mode='bilinear')\n        return x","metadata":{"execution":{"iopub.status.busy":"2022-08-11T06:07:20.859294Z","iopub.execute_input":"2022-08-11T06:07:20.860009Z","iopub.status.idle":"2022-08-11T06:07:20.942787Z","shell.execute_reply.started":"2022-08-11T06:07:20.859973Z","shell.execute_reply":"2022-08-11T06:07:20.941903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def build_model():\n    model = EffUnet(CFG.backbone)\n    model.to(CFG.device)\n    return model\n\ndef load_model(path):\n    model = build_model()\n    model.load_state_dict(torch.load(path))\n    model.eval()\n    return model","metadata":{"execution":{"iopub.status.busy":"2022-08-11T06:07:20.944007Z","iopub.execute_input":"2022-08-11T06:07:20.945117Z","iopub.status.idle":"2022-08-11T06:07:20.951804Z","shell.execute_reply.started":"2022-08-11T06:07:20.945080Z","shell.execute_reply":"2022-08-11T06:07:20.950517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"models = []\nfor path in CFG.ckpt_paths:\n    models.append(load_model(path))","metadata":{"papermill":{"duration":13.838863,"end_time":"2021-03-12T06:33:32.093854","exception":false,"start_time":"2021-03-12T06:33:18.254991","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-11T06:07:20.955979Z","iopub.execute_input":"2022-08-11T06:07:20.956269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Prediction","metadata":{"papermill":{"duration":0.009141,"end_time":"2021-03-12T06:33:32.112738","exception":false,"start_time":"2021-03-12T06:33:32.103597","status":"completed"},"tags":[]}},{"cell_type":"code","source":"test_dataset = HuBMAPDataset(df_sample, tfms=get_transforms(data='valid'))\ntest_dataloader = DataLoader(test_dataset,batch_size = CFG.batch_size,shuffle = False)\nresult,organs = Model_inference(models, test_dataloader)","metadata":{"_kg_hide-output":true,"papermill":{"duration":638.710533,"end_time":"2021-03-12T06:44:10.832427","exception":false,"start_time":"2021-03-12T06:33:32.121894","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rle = []\nfor i, mask in enumerate(result):\n    if organs[i][0] == 'lung':\n        mask = mask > 0.2\n    else:\n        mask = mask > 0.225\n    rle.append(rle_encode_less_memory(mask))\n\ndf = pd.DataFrame({'id':df_sample['id'].values,'rle':rle})\ndf.to_csv('submission.csv',index=False)","metadata":{"papermill":{"duration":0.419953,"end_time":"2021-03-12T06:44:11.262501","exception":false,"start_time":"2021-03-12T06:44:10.842548","status":"completed"},"tags":[],"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(test_dataset[0][0].permute(1,2,0))","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(mask.squeeze().squeeze())","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}