{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":8089,"databundleVersionId":44321,"sourceType":"competition"}],"dockerImageVersionId":30626,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import tensorflow as tf\nimport os\nimport random\nimport numpy as np\n \nfrom tqdm import tqdm \nfrom PIL import Image\n\nfrom skimage.io import imread, imshow\nfrom skimage.transform import resize\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split\n\nfrom keras import layers\nimport keras\nfrom IPython.display import Image, display\nfrom keras.utils import load_img\nfrom keras import utils\nfrom PIL import ImageOps\nfrom tensorflow import data as tf_data\nfrom tensorflow import image as tf_image\nfrom tensorflow import io as tf_io\nfrom tensorflow.keras import Model, models\nfrom tensorflow.keras.applications import ResNet50\nfrom tensorflow.keras.optimizers import Adam","metadata":{"execution":{"iopub.status.busy":"2023-12-15T09:11:54.976486Z","iopub.execute_input":"2023-12-15T09:11:54.976772Z","iopub.status.idle":"2023-12-15T09:12:08.172372Z","shell.execute_reply.started":"2023-12-15T09:11:54.976747Z","shell.execute_reply":"2023-12-15T09:12:08.171328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 1. Data processing (as per Derrick Mwiti's work)","metadata":{}},{"cell_type":"code","source":"from zipfile import ZipFile\nwith ZipFile(\"../input/data-science-bowl-2018/stage1_train.zip\",\"r\") as zip_ref:\n    zip_ref.extractall(\"./stage1_train\")\n    \nwith ZipFile(\"../input/data-science-bowl-2018/stage1_test.zip\",\"r\") as zip_ref:\n    zip_ref.extractall(\"./stage1_test\")","metadata":{"execution":{"iopub.status.busy":"2023-12-15T09:12:08.174510Z","iopub.execute_input":"2023-12-15T09:12:08.175228Z","iopub.status.idle":"2023-12-15T09:12:12.800458Z","shell.execute_reply.started":"2023-12-15T09:12:08.175183Z","shell.execute_reply":"2023-12-15T09:12:12.799667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IMG_WIDTH = 128\nIMG_HEIGHT = 128\nIMG_CHANNELS = 3\n\nTRAIN_PATH = 'stage1_train/'\nTEST_PATH = 'stage1_test/'\n\ntrain_ids = next(os.walk(TRAIN_PATH))[1]\ntest_ids = next(os.walk(TEST_PATH))[1]\n\nx = np.zeros((len(train_ids), IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS), dtype=np.uint8)\ny = np.zeros((len(train_ids), IMG_HEIGHT, IMG_WIDTH, 1), dtype=bool)","metadata":{"execution":{"iopub.status.busy":"2023-12-15T09:12:12.801484Z","iopub.execute_input":"2023-12-15T09:12:12.801798Z","iopub.status.idle":"2023-12-15T09:12:12.809467Z","shell.execute_reply.started":"2023-12-15T09:12:12.801767Z","shell.execute_reply":"2023-12-15T09:12:12.808473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Resizing training images and masks')\nfor n, id_ in tqdm(enumerate(train_ids), total=len(train_ids)):   \n    path = TRAIN_PATH + id_\n    img = imread(path + '/images/' + id_ + '.png')[:,:,:IMG_CHANNELS]  \n    img = resize(img, (IMG_HEIGHT, IMG_WIDTH), mode='constant', preserve_range=True)\n    x[n] = img  #Fill empty X_train with values from img\n    mask = np.zeros((IMG_HEIGHT, IMG_WIDTH, 1), dtype=bool)\n    for mask_file in next(os.walk(path + '/masks/'))[2]:\n        mask_ = imread(path + '/masks/' + mask_file)\n        mask_ = np.expand_dims(resize(mask_, (IMG_HEIGHT, IMG_WIDTH), mode='constant',  \n                                      preserve_range=True), axis=-1)\n        mask = np.maximum(mask, mask_)  \n            \n    y[n] = mask ","metadata":{"execution":{"iopub.status.busy":"2023-12-15T09:12:12.811197Z","iopub.execute_input":"2023-12-15T09:12:12.811469Z","iopub.status.idle":"2023-12-15T09:16:09.553482Z","shell.execute_reply.started":"2023-12-15T09:12:12.811437Z","shell.execute_reply":"2023-12-15T09:16:09.552566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2023-12-15T09:16:09.554780Z","iopub.execute_input":"2023-12-15T09:16:09.555100Z","iopub.status.idle":"2023-12-15T09:16:09.570958Z","shell.execute_reply.started":"2023-12-15T09:16:09.555075Z","shell.execute_reply":"2023-12-15T09:16:09.570204Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train[0].shape","metadata":{"execution":{"iopub.status.busy":"2023-12-15T09:16:09.572021Z","iopub.execute_input":"2023-12-15T09:16:09.572310Z","iopub.status.idle":"2023-12-15T09:16:09.579440Z","shell.execute_reply.started":"2023-12-15T09:16:09.572285Z","shell.execute_reply":"2023-12-15T09:16:09.578495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train.shape","metadata":{"execution":{"iopub.status.busy":"2023-12-15T09:17:34.472872Z","iopub.execute_input":"2023-12-15T09:17:34.473348Z","iopub.status.idle":"2023-12-15T09:17:34.480861Z","shell.execute_reply.started":"2023-12-15T09:17:34.473309Z","shell.execute_reply":"2023-12-15T09:17:34.479630Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_x = random.randint(0, len(x_train))\nplt.axis(\"off\")\nimshow(x_train[image_x])\nplt.show()\nplt.axis(\"off\")\nimshow(np.squeeze(y_train[image_x]))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:15.847921Z","iopub.execute_input":"2023-12-14T23:11:15.848209Z","iopub.status.idle":"2023-12-14T23:11:16.063651Z","shell.execute_reply.started":"2023-12-14T23:11:15.848184Z","shell.execute_reply":"2023-12-14T23:11:16.062408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# test images\ntest_images = np.zeros((len(test_ids), IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS), dtype=np.uint8)\nsizes_test = []\nprint('Resizing test images') \nfor n, id_ in tqdm(enumerate(test_ids), total=len(test_ids)):\n    path = TEST_PATH + id_\n    img = imread(path + '/images/' + id_ + '.png')[:,:,:IMG_CHANNELS]\n    sizes_test.append([img.shape[0], img.shape[1]])\n    img = resize(img, (IMG_HEIGHT, IMG_WIDTH), mode='constant', preserve_range=True)\n    test_images[n] = img\n\nprint('Done!')","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:08:51.234435Z","iopub.execute_input":"2023-12-14T23:08:51.235027Z","iopub.status.idle":"2023-12-14T23:08:52.680907Z","shell.execute_reply.started":"2023-12-14T23:08:51.234975Z","shell.execute_reply":"2023-12-14T23:08:52.680062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Set your input shape and number of classes\ninput_shape = (128, 128, 3)\nnum_classes = 1  # For binary segmentation","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:08:52.684078Z","iopub.execute_input":"2023-12-14T23:08:52.684375Z","iopub.status.idle":"2023-12-14T23:08:52.688802Z","shell.execute_reply.started":"2023-12-14T23:08:52.684350Z","shell.execute_reply":"2023-12-14T23:08:52.687888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 2. U-Net (as per Derrick Mwiti's work)","metadata":{}},{"cell_type":"code","source":"#Build the model\ninputs = tf.keras.layers.Input((IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS))\n\n#Contraction path\nc1 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(inputs)\nc1 = tf.keras.layers.Dropout(0.1)(c1)\nc1 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c1)\nb1 = tf.keras.layers.BatchNormalization()(c1)\nr1 = tf.keras.layers.ReLU()(b1)\np1 = tf.keras.layers.MaxPooling2D((2, 2))(r1)\n\nc2 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p1)\nc2 = tf.keras.layers.Dropout(0.1)(c2)\nc2 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c2)\nb2 = tf.keras.layers.BatchNormalization()(c2)\nr2 = tf.keras.layers.ReLU()(b2)\np2 = tf.keras.layers.MaxPooling2D((2, 2))(r2)\n \nc3 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p2)\nc3 = tf.keras.layers.Dropout(0.2)(c3)\nc3 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c3)\nb3 = tf.keras.layers.BatchNormalization()(c3)\nr3 = tf.keras.layers.ReLU()(b3)\np3 = tf.keras.layers.MaxPooling2D((2, 2))(r3)\n \nc4 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p3)\nc4 = tf.keras.layers.Dropout(0.2)(c4)\nc4 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c4)\nb4 = tf.keras.layers.BatchNormalization()(c4)\nr4 = tf.keras.layers.ReLU()(b4)\np4 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(r4)\n \nc5 = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p4)\nb5 = tf.keras.layers.BatchNormalization()(c5)\nr5 = tf.keras.layers.ReLU()(b5)\nc5 = tf.keras.layers.Dropout(0.3)(r5)\nc5 = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c5)\n\n#Expansive path \nu6 = tf.keras.layers.Conv2DTranspose(128, (2, 2), strides=(2, 2), padding='same')(c5)\nu6 = tf.keras.layers.concatenate([u6, c4])\nu6 = tf.keras.layers.BatchNormalization()(u6)\nu6 = tf.keras.layers.ReLU()(u6)\n\n \nu7 = tf.keras.layers.Conv2DTranspose(64, (2, 2), strides=(2, 2), padding='same')(u6)\nu7 = tf.keras.layers.concatenate([u7, c3])\nu7 = tf.keras.layers.BatchNormalization()(u7)\nu7 = tf.keras.layers.ReLU()(u7)\n\n \nu8 = tf.keras.layers.Conv2DTranspose(32, (2, 2), strides=(2, 2), padding='same')(u7)\nu8 = tf.keras.layers.concatenate([u8, c2])\nu8 = tf.keras.layers.BatchNormalization()(u8)\nu8 = tf.keras.layers.ReLU()(u8)\n \nu9 = tf.keras.layers.Conv2DTranspose(16, (2, 2), strides=(2, 2), padding='same')(u8)\nu9 = tf.keras.layers.concatenate([u9, c1], axis=3)\nu9 = tf.keras.layers.BatchNormalization()(u9)\nu9 = tf.keras.layers.ReLU()(u9)\n\n \noutputs = tf.keras.layers.Conv2D(num_classes, (1, 1), activation='sigmoid')(u9)\n \nmodel_unet = tf.keras.Model(inputs=[inputs], outputs=[outputs])\nmodel_unet.compile(optimizer=Adam(lr=0.005), loss='binary_crossentropy', metrics=['accuracy'])\nmodel_unet.summary()","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:08:52.689852Z","iopub.execute_input":"2023-12-14T23:08:52.690145Z","iopub.status.idle":"2023-12-14T23:08:53.156606Z","shell.execute_reply.started":"2023-12-14T23:08:52.690121Z","shell.execute_reply":"2023-12-14T23:08:53.155478Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"callbacks = [\n        tf.keras.callbacks.EarlyStopping(patience=2, monitor='val_loss'),\n        tf.keras.callbacks.TensorBoard(log_dir='logs')]\n\nmodel_unet.fit(x_train, y_train, validation_data=(x_test,y_test), batch_size=16, epochs=25, callbacks=callbacks)","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:08:53.158130Z","iopub.execute_input":"2023-12-14T23:08:53.158532Z","iopub.status.idle":"2023-12-14T23:09:10.791806Z","shell.execute_reply.started":"2023-12-14T23:08:53.158486Z","shell.execute_reply":"2023-12-14T23:09:10.790776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy = model_unet.history.history['accuracy']\nval_accuracy = model_unet.history.history['val_accuracy']\n\nplt.figure()\nplt.plot( accuracy, 'r', label='Training accuracy')\nplt.plot( val_accuracy, 'bo', label='Validation accuracy')\nplt.title('Training and Validation accuracy')\nplt.xlabel('Epoch')\nplt.ylabel('Loss Value')\nplt.ylim([0, 1])\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:09:10.793057Z","iopub.execute_input":"2023-12-14T23:09:10.793360Z","iopub.status.idle":"2023-12-14T23:09:11.016952Z","shell.execute_reply.started":"2023-12-14T23:09:10.793335Z","shell.execute_reply":"2023-12-14T23:09:11.015997Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 3. ResNet50","metadata":{}},{"cell_type":"code","source":"def create_resnet_segmentation_model(input_shape, num_classes, weights=None):\n    base_model = ResNet50(input_shape=input_shape, include_top=False, weights=weights)\n\n    # Freeze layers\n    if (weights != None):\n        for layer in base_model.layers[:-12]:\n            layer.trainable = False\n\n    base_output = base_model.output\n\n    # Upsample to match the original input size (128, 128)\n   \n\n    x = layers.Conv2DTranspose(128, (3, 3), strides=(2, 2), padding='same')(base_output)\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation('relu')(x)\n    x = layers.UpSampling2D(size=(2, 2))(x)\n    \n    x = layers.Conv2DTranspose(128, (3, 3), strides=(2, 2), padding='same')(x)\n    x = layers.BatchNormalization()(x)\n    x = layers.Activation('relu')(x)\n    x = layers.UpSampling2D(size=(2, 2))(x)\n\n    # Adjust the number of filters in the Conv2DTranspose layers based on your specific requirements\n    x = layers.UpSampling2D(size=(2, 2))(x)\n    segmentation_output = layers.Conv2D(num_classes, (1, 1), activation='sigmoid', padding='same')(x)\n\n    model = models.Model(inputs=base_model.input, outputs=segmentation_output)\n\n    return model\n\n# Create the ResNet segmentation model\nmodel_resnet = create_resnet_segmentation_model(input_shape, num_classes)\n\n# Create the ResNet pretrained segmentation model\nmodel_resnet_tf = create_resnet_segmentation_model(input_shape, num_classes, 'imagenet')\n\n# Compile the model with binary crossentropy\nmodel_resnet.compile(optimizer=Adam(lr=0.005), loss='binary_crossentropy', metrics=['accuracy'])\nmodel_resnet_tf.compile(optimizer=Adam(lr=0.005), loss='binary_crossentropy', metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:09:11.018038Z","iopub.execute_input":"2023-12-14T23:09:11.018318Z","iopub.status.idle":"2023-12-14T23:09:14.539428Z","shell.execute_reply.started":"2023-12-14T23:09:11.018295Z","shell.execute_reply":"2023-12-14T23:09:14.538679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"callbacks = [\n    tf.keras.callbacks.EarlyStopping(patience=10, monitor='val_loss'),\n    tf.keras.callbacks.TensorBoard(log_dir='logs')\n]\n\nmodel_resnet.fit(x_train, y_train, validation_data=(x_test, y_test), batch_size=16, epochs=25, callbacks=callbacks)","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:09:14.540568Z","iopub.execute_input":"2023-12-14T23:09:14.540866Z","iopub.status.idle":"2023-12-14T23:10:44.920587Z","shell.execute_reply.started":"2023-12-14T23:09:14.540841Z","shell.execute_reply":"2023-12-14T23:10:44.919657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy = model_resnet.history.history['accuracy']\nval_accuracy = model_resnet.history.history['val_accuracy']\n\nplt.figure()\nplt.plot( accuracy, 'r', label='Training accuracy')\nplt.plot( val_accuracy, 'bo', label='Validation accuracy')\nplt.title('Training and Validation accuracy')\nplt.xlabel('Epoch')\nplt.ylabel('Loss Value')\nplt.ylim([0, 1])\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:10:44.921878Z","iopub.execute_input":"2023-12-14T23:10:44.922177Z","iopub.status.idle":"2023-12-14T23:10:45.136074Z","shell.execute_reply.started":"2023-12-14T23:10:44.922151Z","shell.execute_reply":"2023-12-14T23:10:45.135050Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 4. ResNet50 with transfer learning","metadata":{}},{"cell_type":"code","source":"callbacks = [\n    tf.keras.callbacks.EarlyStopping(patience=10, monitor='val_loss'),\n    tf.keras.callbacks.TensorBoard(log_dir='logs')\n]\n\nmodel_resnet_tf.fit(x_train, y_train, validation_data=(x_test, y_test), batch_size=16, epochs=25, callbacks=callbacks)","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:10:45.137449Z","iopub.execute_input":"2023-12-14T23:10:45.137829Z","iopub.status.idle":"2023-12-14T23:11:11.925133Z","shell.execute_reply.started":"2023-12-14T23:10:45.137795Z","shell.execute_reply":"2023-12-14T23:11:11.924284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy = model_resnet_tf.history.history['accuracy']\nval_accuracy = model_resnet_tf.history.history['val_accuracy']\n\nplt.figure()\nplt.plot( accuracy, 'r', label='Training accuracy')\nplt.plot( val_accuracy, 'bo', label='Validation accuracy')\nplt.title('Training and Validation accuracy')\nplt.xlabel('Epoch')\nplt.ylabel('Loss Value')\nplt.ylim([0, 1])\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:11.926149Z","iopub.execute_input":"2023-12-14T23:11:11.926414Z","iopub.status.idle":"2023-12-14T23:11:12.160600Z","shell.execute_reply.started":"2023-12-14T23:11:11.926391Z","shell.execute_reply":"2023-12-14T23:11:12.159687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 5. Results","metadata":{}},{"cell_type":"code","source":"def display(display_list):\n    plt.figure(figsize=(15, 15))\n\n    title = ['Input image', 'True mask', 'Predicted mask']\n\n    for i in range(len(display_list)):\n        plt.subplot(1, len(display_list), i+1)\n        plt.title(title[i])\n        plt.imshow(tf.keras.utils.array_to_img(display_list[i]))\n        plt.axis('off')\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:12.162034Z","iopub.execute_input":"2023-12-14T23:11:12.162425Z","iopub.status.idle":"2023-12-14T23:11:12.168867Z","shell.execute_reply.started":"2023-12-14T23:11:12.162390Z","shell.execute_reply":"2023-12-14T23:11:12.167883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"i = random.randint(0, len(x_test))\nsample_image = x_test[i]\nsample_mask = y_test[i]","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:12.170061Z","iopub.execute_input":"2023-12-14T23:11:12.170333Z","iopub.status.idle":"2023-12-14T23:11:12.178516Z","shell.execute_reply.started":"2023-12-14T23:11:12.170309Z","shell.execute_reply":"2023-12-14T23:11:12.177784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction_unet = model_unet.predict(sample_image[tf.newaxis, ...])[0]\nprediction_resnet = model_resnet.predict(sample_image[tf.newaxis, ...])[0]\nprediction_resnet_tf = model_resnet_tf.predict(sample_image[tf.newaxis, ...])[0]","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:12.179588Z","iopub.execute_input":"2023-12-14T23:11:12.180005Z","iopub.status.idle":"2023-12-14T23:11:14.694626Z","shell.execute_reply.started":"2023-12-14T23:11:12.179973Z","shell.execute_reply":"2023-12-14T23:11:14.693802Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_mask_unet = (prediction_unet > 0.5).astype(np.uint8)\npredicted_mask_resnet = (prediction_resnet > 0.5).astype(np.uint8)\npredicted_mask_resnet_tf = (prediction_resnet_tf > 0.5).astype(np.uint8)","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:14.695829Z","iopub.execute_input":"2023-12-14T23:11:14.696120Z","iopub.status.idle":"2023-12-14T23:11:14.701966Z","shell.execute_reply.started":"2023-12-14T23:11:14.696095Z","shell.execute_reply":"2023-12-14T23:11:14.701034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display([sample_image, sample_mask, predicted_mask_unet])","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:14.703231Z","iopub.execute_input":"2023-12-14T23:11:14.703574Z","iopub.status.idle":"2023-12-14T23:11:15.085960Z","shell.execute_reply.started":"2023-12-14T23:11:14.703547Z","shell.execute_reply":"2023-12-14T23:11:15.085010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display([sample_image, sample_mask, predicted_mask_resnet])","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:15.087226Z","iopub.execute_input":"2023-12-14T23:11:15.087561Z","iopub.status.idle":"2023-12-14T23:11:15.465639Z","shell.execute_reply.started":"2023-12-14T23:11:15.087531Z","shell.execute_reply":"2023-12-14T23:11:15.464717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display([sample_image, sample_mask, predicted_mask_resnet_tf])","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:11:15.469359Z","iopub.execute_input":"2023-12-14T23:11:15.469661Z","iopub.status.idle":"2023-12-14T23:11:15.846810Z","shell.execute_reply.started":"2023-12-14T23:11:15.469635Z","shell.execute_reply":"2023-12-14T23:11:15.845947Z"},"trusted":true},"execution_count":null,"outputs":[]}]}