{"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 segmentation_models_pytorch\n!pip install warmup_scheduler\n","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:39:29.556469Z","iopub.execute_input":"2023-05-27T20:39:29.556734Z","iopub.status.idle":"2023-05-27T20:40:02.005812Z","shell.execute_reply.started":"2023-05-27T20:39:29.556710Z","shell.execute_reply":"2023-05-27T20:40:02.004372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from torch.utils.data import DataLoader\nfrom torch.cuda.amp import autocast, GradScaler\nimport sys\nimport time\nimport torch as tc\nimport random\nfrom torch.utils.data import DataLoader, Dataset\nimport torch\nimport albumentations as A\nfrom albumentations.pytorch import ToTensorV2\nimport numpy as np\n\nfrom tqdm.auto import tqdm\n\nimport torch\nimport torch.nn as nn\nfrom torch.optim import AdamW\n\nfrom torch.utils.data import DataLoader, Dataset\nimport matplotlib.pyplot as plt\nimport cv2,gc\nimport os,warnings\nimport pandas as pd","metadata":{"papermill":{"duration":3.930964,"end_time":"2023-05-24T10:08:16.674796","exception":false,"start_time":"2023-05-24T10:08:12.743832","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:02.008591Z","iopub.execute_input":"2023-05-27T20:40:02.008970Z","iopub.status.idle":"2023-05-27T20:40:07.162854Z","shell.execute_reply.started":"2023-05-27T20:40:02.008934Z","shell.execute_reply":"2023-05-27T20:40:07.161893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import segmentation_models_pytorch as smp","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:40:07.164396Z","iopub.execute_input":"2023-05-27T20:40:07.164724Z","iopub.status.idle":"2023-05-27T20:40:09.061866Z","shell.execute_reply.started":"2023-05-27T20:40:07.164694Z","shell.execute_reply":"2023-05-27T20:40:09.060887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## config","metadata":{"papermill":{"duration":0.008035,"end_time":"2023-05-24T10:08:19.433694","exception":false,"start_time":"2023-05-24T10:08:19.425659","status":"completed"},"tags":[]}},{"cell_type":"code","source":"import os\nimport albumentations as A\nfrom albumentations.pytorch import ToTensorV2\n\nclass CFG:\n    # ============== comp exp name =============\n    comp_dir_path = '/kaggle/input/'\n    comp_folder_name = 'vesuvius-dataset-split-5'\n    # comp_dataset_path = f'{comp_dir_path}datasets/{comp_folder_name}/'\n    comp_dataset_path = f'{comp_dir_path}{comp_folder_name}/'\n    \n    exp_name = 'vesuvius_2d_slide_exp002'\n\n    # ============== pred target =============\n    target_size = 1\n    TTA=True\n    \n    # ============== model cfg =============\n    model_name = 'Unet'\n    # backbone = 'efficientnet-b0'\n    backbone = 'mit_b2'\n\n    start_chans=27\n    end_chans=30\n    in_chans=end_chans-start_chans\n    # ============== training cfg =============\n    size = 224\n    tile_size = 224\n    stride = tile_size // 4\n\n    batch_size = 8 # 32\n    use_amp = True\n\n\n    # ============== fixed =============\n    pretrained = True\n    num_workers = 2\n\n    seed = 42\n    valid_aug_list = [\n        A.Resize(size, size),\n        A.Normalize(\n            mean= [0] * in_chans,\n            std= [1] * in_chans\n        ),\n        ToTensorV2(transpose_mask=True),\n    ]\n","metadata":{"papermill":{"duration":0.028839,"end_time":"2023-05-24T10:08:19.470760","exception":false,"start_time":"2023-05-24T10:08:19.441921","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:09.064872Z","iopub.execute_input":"2023-05-27T20:40:09.065288Z","iopub.status.idle":"2023-05-27T20:40:09.077100Z","shell.execute_reply.started":"2023-05-27T20:40:09.065252Z","shell.execute_reply":"2023-05-27T20:40:09.073692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nTH = 0.6\n\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')","metadata":{"papermill":{"duration":0.016576,"end_time":"2023-05-24T10:08:19.495625","exception":false,"start_time":"2023-05-24T10:08:19.479049","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:09.078833Z","iopub.execute_input":"2023-05-27T20:40:09.079219Z","iopub.status.idle":"2023-05-27T20:40:09.129363Z","shell.execute_reply.started":"2023-05-27T20:40:09.079186Z","shell.execute_reply":"2023-05-27T20:40:09.128422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## dataset","metadata":{"papermill":{"duration":0.007805,"end_time":"2023-05-24T10:08:22.835247","exception":false,"start_time":"2023-05-24T10:08:22.827442","status":"completed"},"tags":[]}},{"cell_type":"code","source":"\ndef read_image(fragment_id):\n\n    images = []\n    \n    start = CFG.start_chans\n    end=CFG.end_chans\n    idxs = range(start, end)\n\n    for i in tqdm(idxs):\n        \n        image = cv2.imread(CFG.comp_dataset_path + f\"train/{fragment_id}/surface_volume/{i:02}.tif\", 0)\n        \n\n        pad0 = (CFG.tile_size - image.shape[0] % CFG.tile_size)\n        pad1 = (CFG.tile_size - image.shape[1] % CFG.tile_size)\n\n        image = np.pad(image, [(0, pad0), (0, pad1)], constant_values=0)\n\n        images.append(image)\n    images = np.stack(images, axis=2)\n    \n    return images\ndef get_transforms(data, cfg):\n    if data == 'train':\n        aug = A.Compose(cfg.train_aug_list)\n    elif data == 'valid':\n        aug = A.Compose(cfg.valid_aug_list)\n\n    # print(aug)\n    return aug\n\nclass CustomDataset(Dataset):\n    def __init__(self, images, cfg, labels=None, transform=None):\n        self.images = images\n        self.cfg = cfg\n        self.labels = labels\n        self.transform = transform\n\n    def __len__(self):\n        # return len(self.xyxys)\n        return len(self.images)\n\n    def __getitem__(self, idx):\n        # x1, y1, x2, y2 = self.xyxys[idx]\n        image = self.images[idx]\n        data = self.transform(image=image)\n        image = data['image']\n        return image\n\ndef make_test_dataset(fragment_id):\n    test_images = read_image(fragment_id)\n    \n    x1_list = list(range(0, test_images.shape[1]-CFG.tile_size+1, CFG.stride))\n    y1_list = list(range(0, test_images.shape[0]-CFG.tile_size+1, CFG.stride))\n    \n    test_images_list = []\n    xyxys = []\n    for y1 in y1_list:\n        for x1 in x1_list:\n            y2 = y1 + CFG.tile_size\n            x2 = x1 + CFG.tile_size\n            \n            test_images_list.append(test_images[y1:y2, x1:x2])\n            xyxys.append((x1, y1, x2, y2))\n    xyxys = np.stack(xyxys)\n            \n    test_dataset = CustomDataset(test_images_list, CFG, transform=get_transforms(data='valid', cfg=CFG))\n    \n    test_loader = DataLoader(test_dataset,\n                          batch_size=CFG.batch_size,\n                          shuffle=False,\n                          num_workers=CFG.num_workers, pin_memory=True, drop_last=False)\n    \n    return test_loader, xyxys","metadata":{"papermill":{"duration":0.019465,"end_time":"2023-05-24T10:08:22.862529","exception":false,"start_time":"2023-05-24T10:08:22.843064","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:09.130688Z","iopub.execute_input":"2023-05-27T20:40:09.131015Z","iopub.status.idle":"2023-05-27T20:40:09.146388Z","shell.execute_reply.started":"2023-05-27T20:40:09.130983Z","shell.execute_reply":"2023-05-27T20:40:09.145501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## model","metadata":{"papermill":{"duration":0.008162,"end_time":"2023-05-24T10:08:22.934725","exception":false,"start_time":"2023-05-24T10:08:22.926563","status":"completed"},"tags":[]}},{"cell_type":"code","source":"class CustomModel(nn.Module):\n    def __init__(self):\n        super().__init__()\n\n        self.encoder02=smp.Unet(\n            encoder_name=\"mit_b2\", \n            encoder_weights=None,\n            in_channels=3,\n            classes=1,\n            activation=None,\n        )\n        self.stacked_unet=nn.Sequential(self.encoder02)\n\n    def forward(self, image):\n\n        output=self.stacked_unet(image)\n        return output","metadata":{"papermill":{"duration":0.024806,"end_time":"2023-05-24T10:08:22.982997","exception":false,"start_time":"2023-05-24T10:08:22.958191","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:09.147968Z","iopub.execute_input":"2023-05-27T20:40:09.148360Z","iopub.status.idle":"2023-05-27T20:40:09.162202Z","shell.execute_reply.started":"2023-05-27T20:40:09.148278Z","shell.execute_reply":"2023-05-27T20:40:09.161231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class EnsembleModel:\n    def __init__(self, use_tta=False):\n        self.models = []\n        self.use_tta = use_tta\n\n    def __call__(self, x):\n        outputs = [torch.sigmoid(model(x)).to('cpu').numpy()\n                   for model in self.models]\n        avg_preds = np.mean(outputs, axis=0)\n        return avg_preds\n\n    def add_model(self, model):\n        self.models.append(model)\n\ndef build_ensemble_model(model_pths):\n\n    model = EnsembleModel()\n    for path in model_pths:\n\n        _model=CustomModel()\n        data=torch.load(path)\n        \n        weights=data['weights']\n        encoder=data['encoder']\n        _model.stacked_unet=encoder\n        _model.to(device)\n        model_path = path\n\n        _model.load_state_dict(weights)\n        _model.eval()\n        \n        model.add_model(_model)\n    \n    return model","metadata":{"papermill":{"duration":0.023886,"end_time":"2023-05-24T10:08:23.038721","exception":false,"start_time":"2023-05-24T10:08:23.014835","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:09.163768Z","iopub.execute_input":"2023-05-27T20:40:09.164087Z","iopub.status.idle":"2023-05-27T20:40:09.173574Z","shell.execute_reply.started":"2023-05-27T20:40:09.164058Z","shell.execute_reply":"2023-05-27T20:40:09.172715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def TTA(x:torch.Tensor,model:nn.Module):\n    #x.shape=(batch,c,h,w)\n    shape=x.shape\n    x=[x,*[torch.rot90(x,k=i,dims=(-2,-1)) for i in range(1,4)]]\n    x=torch.cat(x,dim=0)\n    x=model(x)\n    x=torch.Tensor(x.reshape(4,shape[0],1,*shape[-2:]))\n    x=[torch.rot90(x[i],k=-i,dims=(-2,-1)) for i in range(4)]\n    x=torch.stack(x,dim=0)\n    return x.mean(0)","metadata":{"papermill":{"duration":0.022101,"end_time":"2023-05-24T10:08:23.068603","exception":false,"start_time":"2023-05-24T10:08:23.046502","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:09.175020Z","iopub.execute_input":"2023-05-27T20:40:09.175412Z","iopub.status.idle":"2023-05-27T20:40:09.185250Z","shell.execute_reply.started":"2023-05-27T20:40:09.175382Z","shell.execute_reply":"2023-05-27T20:40:09.184439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import fbeta_score\n\ndef fbeta_numpy(targets, preds, beta=0.5, smooth=1e-5):\n    \"\"\"\n    https://www.kaggle.com/competitions/vesuvius-challenge-ink-detection/discussion/397288\n    \"\"\"\n    y_true_count = targets.sum()\n    ctp = preds[targets==1].sum()\n    cfp = preds[targets==0].sum()\n    beta_squared = beta * beta\n\n    c_precision = ctp / (ctp + cfp + smooth)\n    c_recall = ctp / (y_true_count + smooth)\n    dice = (1 + beta_squared) * (c_precision * c_recall) / (beta_squared * c_precision + c_recall + smooth)\n\n    return dice\n\ndef calc_fbeta(mask, mask_pred):\n    mask = mask.astype(int).flatten()\n    mask_pred = mask_pred.flatten()\n\n    best_th = 0\n    best_dice = 0\n    \n    for th in np.array(range(0, 100+1, 5)) / 100:\n        \n        # dice = fbeta_score(mask, (mask_pred >= th).astype(int), beta=0.5)\n        dice = fbeta_numpy(mask, (mask_pred >= th).astype(int), beta=0.5)\n        print(f'th: {th}, fbeta: {dice}')\n\n        if dice > best_dice:\n            best_dice = dice\n            best_th = th\n    \n    return best_dice, best_th\n\n\ndef calc_cv(mask_gt, mask_pred):\n    best_dice, best_th = calc_fbeta(mask_gt, mask_pred)\n\n    return best_dice, best_th","metadata":{"papermill":{"duration":48.794243,"end_time":"2023-05-24T10:09:11.870629","exception":false,"start_time":"2023-05-24T10:08:23.076386","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:40:09.188764Z","iopub.execute_input":"2023-05-27T20:40:09.189084Z","iopub.status.idle":"2023-05-27T20:40:09.199428Z","shell.execute_reply.started":"2023-05-27T20:40:09.189060Z","shell.execute_reply":"2023-05-27T20:40:09.198564Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## main","metadata":{"papermill":{"duration":0.008756,"end_time":"2023-05-24T10:09:11.889477","exception":false,"start_time":"2023-05-24T10:09:11.880721","status":"completed"},"tags":[]}},{"cell_type":"code","source":"\ndef predict_and_save_results(fragment_id, model):\n\n\n\n    # Prepare the test dataset\n    test_loader, xyxys = make_test_dataset(fragment_id)\n\n    # Load the ground truth mask\n    binary_mask = cv2.imread(CFG.comp_dataset_path + f\"train/{fragment_id}/mask.png\", 0)\n    binary_mask = (binary_mask / 255).astype(int)\n    ori_h = binary_mask.shape[0]\n    ori_w = binary_mask.shape[1]\n    pad0 = (CFG.tile_size - binary_mask.shape[0] % CFG.tile_size)\n    pad1 = (CFG.tile_size - binary_mask.shape[1] % CFG.tile_size)\n    binary_mask = np.pad(binary_mask, [(0, pad0), (0, pad1)], constant_values=0)\n\n    # Perform predictions\n    mask_pred = np.zeros(binary_mask.shape)\n    mask_count = np.zeros(binary_mask.shape)\n    for step, (images) in tqdm(enumerate(test_loader), total=len(test_loader)):\n        images = images.cuda()\n        batch_size = images.size(0)\n        with torch.no_grad():\n            y_preds = TTA(images, model).cpu().numpy()\n#             y_preds = model(images)\n\n\n        start_idx = step * CFG.batch_size\n        end_idx = start_idx + batch_size\n        for i, (x1, y1, x2, y2) in enumerate(xyxys[start_idx:end_idx]):\n            mask_pred[y1:y2, x1:x2] += y_preds[i].reshape(mask_pred[y1:y2, x1:x2].shape)\n            mask_count[y1:y2, x1:x2] += np.ones((CFG.tile_size, CFG.tile_size))\n\n    mask_pred /= mask_count\n    mask_pred *= binary_mask\n    mask_gt=(cv2.imread(f\"/kaggle/input/vesuvius-dataset-split-5/train/{fragment_id}/inklabels.png\", 0)/255).astype(int)\n    print(mask_gt.shape, (ori_h, ori_w))\n\n\n    cv2.imwrite(f\"/kaggle/working/preds_labels_{fragment_id}.png\", mask_pred[0:ori_h, 0:ori_w])\n    cv2.imwrite(f\"/kaggle/working/true_labels_{fragment_id}.png\", mask_gt)\n    calc_cv(mask_gt, mask_pred[0:ori_h, 0:ori_w])\n\n\n    # Clean up\n    del mask_pred, mask_count, test_loader, model\n    gc.collect()\n    torch.cuda.empty_cache()\n","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:43:49.716359Z","iopub.execute_input":"2023-05-27T20:43:49.716805Z","iopub.status.idle":"2023-05-27T20:43:49.738232Z","shell.execute_reply.started":"2023-05-27T20:43:49.716763Z","shell.execute_reply":"2023-05-27T20:43:49.737362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"results = []\nfragment_ids=[1,2,3,4,5,6]\n\nmodel_paths=[ \n        \"/kaggle/input/good-models/six_fold_mit_b2_fold_1_best.pth\",\n        \"/kaggle/input/good-models/six_fold_mit_b2_fold_2_best.pth\",\n        \"/kaggle/input/good-models/six_fold_mit_b2_fold_3_best.pth\",\n        \"/kaggle/input/good-models/six_fold_mit_b2_fold_4_best.pth\",\n        \"/kaggle/input/good-models/six_fold_mit_b2_fold_5_best.pth\",\n        \"/kaggle/input/good-models/six_fold_mit_b2_fold_6_best.pth\"\n]\n\nfor fragment_id in fragment_ids:\n    model_path=model_paths\n    model=build_ensemble_model(model_path)\n    predict_and_save_results(fragment_id, model)\n  ","metadata":{"papermill":{"duration":16526.952629,"end_time":"2023-05-24T14:44:38.851057","exception":false,"start_time":"2023-05-24T10:09:11.898428","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-05-27T20:49:15.914380Z","iopub.execute_input":"2023-05-27T20:49:15.914804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# th: 0.0, fbeta: 0.15116101344554894\n# th: 0.05, fbeta: 0.5331096278844794\n# th: 0.1, fbeta: 0.6243767184601398\n# th: 0.15, fbeta: 0.6757416131586094\n# th: 0.2, fbeta: 0.7089620127004245\n# th: 0.25, fbeta: 0.7331739453278411\n# th: 0.3, fbeta: 0.7499816310207886\n# th: 0.35, fbeta: 0.7597840328701956\n# th: 0.4, fbeta: 0.7651440488185178\n# th: 0.45, fbeta: 0.7615412584793813\n# th: 0.5, fbeta: 0.7426927540085583\n# th: 0.55, fbeta: 0.7101917412890534\n# th: 0.6, fbeta: 0.6732075744273077\n# th: 0.65, fbeta: 0.6329492194588547\n# th: 0.7, fbeta: 0.5899610543366846\n# th: 0.75, fbeta: 0.5421347518650724\n# th: 0.8, fbeta: 0.485570762265655\n# th: 0.85, fbeta: 0.41835939411397033\n# th: 0.9, fbeta: 0.3441424112530353\n# th: 0.95, fbeta: 0.22912602671182405\n# th: 1.0, fbeta: 0.0","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nfrom PIL import Image\n\ndef visualize_images(image_path1, image_path2):\n    # Load the images\n    image1 = Image.open(image_path1)\n    image2 = Image.open(image_path2)\n\n    # Create a figure with two subplots\n    fig, axes = plt.subplots(1, 2)\n\n    # Display the first image on the left subplot\n    axes[0].imshow(image1)\n    axes[0].set_title('Image 1')\n\n    # Display the second image on the right subplot\n    axes[1].imshow(image2)\n    axes[1].set_title('Image 2')\n\n    # Adjust the spacing between subplots\n    plt.tight_layout()\n\n    # Show the plot\n    plt.show()\n\n","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:43:08.234435Z","iopub.execute_input":"2023-05-27T20:43:08.234803Z","iopub.status.idle":"2023-05-27T20:43:08.244193Z","shell.execute_reply.started":"2023-05-27T20:43:08.234772Z","shell.execute_reply":"2023-05-27T20:43:08.243265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_path1 = \"/kaggle/working/preds_labels_1.png\"\nimage_path2 = '/kaggle/working/true_labels_1.png'\nvisualize_images(image_path1, image_path2)","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:43:08.462932Z","iopub.execute_input":"2023-05-27T20:43:08.463208Z","iopub.status.idle":"2023-05-27T20:43:11.584355Z","shell.execute_reply.started":"2023-05-27T20:43:08.463185Z","shell.execute_reply":"2023-05-27T20:43:11.583462Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_path1 = \"/kaggle/working/preds_labels_2.png\"\nimage_path2 = '/kaggle/working/true_labels_2.png'\nvisualize_images(image_path1, image_path2)","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:10:56.606621Z","iopub.status.idle":"2023-05-27T20:10:56.607082Z","shell.execute_reply.started":"2023-05-27T20:10:56.606845Z","shell.execute_reply":"2023-05-27T20:10:56.606867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_path1 = \"/kaggle/working/preds_labels_3.png\"\nimage_path2 = '/kaggle/working/true_labels_3.png'\nvisualize_images(image_path1, image_path2)","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:01:24.785197Z","iopub.execute_input":"2023-05-27T20:01:24.785636Z","iopub.status.idle":"2023-05-27T20:01:27.943842Z","shell.execute_reply.started":"2023-05-27T20:01:24.785601Z","shell.execute_reply":"2023-05-27T20:01:27.942925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_path1 = \"/kaggle/working/preds_labels_4.png\"\nimage_path2 = '/kaggle/working/true_labels_4.png'\nvisualize_images(image_path1, image_path2)","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:01:27.945527Z","iopub.execute_input":"2023-05-27T20:01:27.946461Z","iopub.status.idle":"2023-05-27T20:01:31.117405Z","shell.execute_reply.started":"2023-05-27T20:01:27.946432Z","shell.execute_reply":"2023-05-27T20:01:31.116482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_path1 = \"/kaggle/working/preds_labels_5.png\"\nimage_path2 = '/kaggle/working/true_labels_5.png'\nvisualize_images(image_path1, image_path2)","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:01:31.118808Z","iopub.execute_input":"2023-05-27T20:01:31.119191Z","iopub.status.idle":"2023-05-27T20:01:34.547901Z","shell.execute_reply.started":"2023-05-27T20:01:31.119157Z","shell.execute_reply":"2023-05-27T20:01:34.546827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_path1 = \"/kaggle/working/preds_labels_6.png\"\nimage_path2 = '/kaggle/working/true_labels_6.png'\nvisualize_images(image_path1, image_path2)","metadata":{"execution":{"iopub.status.busy":"2023-05-27T20:01:34.549640Z","iopub.execute_input":"2023-05-27T20:01:34.549997Z","iopub.status.idle":"2023-05-27T20:01:37.691830Z","shell.execute_reply.started":"2023-05-27T20:01:34.549965Z","shell.execute_reply":"2023-05-27T20:01:37.690768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}