{"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":"<center><h1 class=\"list-group-item list-group-item-success\">Automatic Nucleus detection</h1></center>","metadata":{"execution":{"iopub.status.busy":"2023-01-09T16:29:04.177186Z","iopub.execute_input":"2023-01-09T16:29:04.177675Z","iopub.status.idle":"2023-01-09T16:29:04.203357Z","shell.execute_reply.started":"2023-01-09T16:29:04.177579Z","shell.execute_reply":"2023-01-09T16:29:04.201814Z"}}},{"cell_type":"markdown","source":"<img src = \"https://storage.googleapis.com/kaggle-media/competitions/dsb-2018/dsb.jpg\">","metadata":{"execution":{"iopub.status.busy":"2023-01-09T16:30:05.001947Z","iopub.execute_input":"2023-01-09T16:30:05.002379Z","iopub.status.idle":"2023-01-09T16:30:05.009294Z","shell.execute_reply.started":"2023-01-09T16:30:05.002343Z","shell.execute_reply":"2023-01-09T16:30:05.007913Z"}}},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Importing Packages</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"code","source":"import tensorflow as tf\nimport os\nimport random\nimport numpy as np\nfrom tqdm import tqdm \nfrom skimage.io import imread, imshow\nfrom skimage.transform import resize\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split\nfrom zipfile import ZipFile","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-01-09T17:40:19.811625Z","iopub.execute_input":"2023-01-09T17:40:19.812344Z","iopub.status.idle":"2023-01-09T17:40:19.817789Z","shell.execute_reply.started":"2023-01-09T17:40:19.812305Z","shell.execute_reply":"2023-01-09T17:40:19.816764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Loading Data</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"code","source":"# Extracting Stage 1 train data\nwith ZipFile(\"../input/data-science-bowl-2018/stage1_train.zip\",\"r\") as zip_ref:\n    zip_ref.extractall(\"./stage1_train\")\n    \n# Extracting Stage 1 test data\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-01-09T17:40:19.823474Z","iopub.execute_input":"2023-01-09T17:40:19.824344Z","iopub.status.idle":"2023-01-09T17:40:25.93346Z","shell.execute_reply.started":"2023-01-09T17:40:19.824304Z","shell.execute_reply":"2023-01-09T17:40:25.932375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Setting parameters for loading data\n\n# Setting up seed value\nseed = 42\nnp.random.seed = seed\n\n# Image Dimensions\nIMG_WIDTH = 128\nIMG_HEIGHT = 128\nIMG_CHANNELS = 3\n\n# Setting data path\nTRAIN_PATH = 'stage1_train/'\nTEST_PATH = 'stage1_test/'\n\n# Saving IDs\ntrain_ids = next(os.walk(TRAIN_PATH))[1]\ntest_ids = next(os.walk(TEST_PATH))[1]\n\n# Setting up X & Y\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-01-09T17:40:25.93551Z","iopub.execute_input":"2023-01-09T17:40:25.935901Z","iopub.status.idle":"2023-01-09T17:40:25.95528Z","shell.execute_reply.started":"2023-01-09T17:40:25.935864Z","shell.execute_reply":"2023-01-09T17:40:25.954426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Loading train data and transforming to the required shape \nprint('Resizing training images and masks')\nfor n, id_ in tqdm(enumerate(train_ids), total=len(train_ids)):   \n    path = TRAIN_PATH + id_\n    # Reading images\n    img = imread(path + '/images/' + id_ + '.png')[:,:,:IMG_CHANNELS]  \n    # Transforming images\n    img = resize(img, (IMG_HEIGHT, IMG_WIDTH), mode='constant', preserve_range=True)\n    X[n] = img \n    # Creating a mask\n    mask = np.zeros((IMG_HEIGHT, IMG_WIDTH, 1), dtype=bool)\n    for mask_file in next(os.walk(path + '/masks/'))[2]:\n        # Loading mask data\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    y[n] = mask ","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:40:25.956834Z","iopub.execute_input":"2023-01-09T17:40:25.957208Z","iopub.status.idle":"2023-01-09T17:44:30.398707Z","shell.execute_reply.started":"2023-01-09T17:40:25.957171Z","shell.execute_reply":"2023-01-09T17:44:30.397641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Loading test data and transforming to the required shape \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","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:30.401597Z","iopub.execute_input":"2023-01-09T17:44:30.402521Z","iopub.status.idle":"2023-01-09T17:44:31.772972Z","shell.execute_reply.started":"2023-01-09T17:44:30.402479Z","shell.execute_reply":"2023-01-09T17:44:31.771903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Train Test Split</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"code","source":"# Train test split with 20% split ratio\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:31.774353Z","iopub.execute_input":"2023-01-09T17:44:31.774952Z","iopub.status.idle":"2023-01-09T17:44:31.792261Z","shell.execute_reply.started":"2023-01-09T17:44:31.774914Z","shell.execute_reply":"2023-01-09T17:44:31.791265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Displaying a random data with its mask\nimage_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-01-09T17:44:31.794734Z","iopub.execute_input":"2023-01-09T17:44:31.795067Z","iopub.status.idle":"2023-01-09T17:44:32.014015Z","shell.execute_reply.started":"2023-01-09T17:44:31.79504Z","shell.execute_reply":"2023-01-09T17:44:32.012678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Data Modelling</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"code","source":"# Defining Params\nnum_classes = 1","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.015667Z","iopub.execute_input":"2023-01-09T17:44:32.016315Z","iopub.status.idle":"2023-01-09T17:44:32.020592Z","shell.execute_reply.started":"2023-01-09T17:44:32.016272Z","shell.execute_reply":"2023-01-09T17:44:32.019485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Input layer\ninputs = tf.keras.layers.Input(shape=(None, None, 3))","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.022647Z","iopub.execute_input":"2023-01-09T17:44:32.023553Z","iopub.status.idle":"2023-01-09T17:44:32.032598Z","shell.execute_reply.started":"2023-01-09T17:44:32.023509Z","shell.execute_reply":"2023-01-09T17:44:32.030913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Model encoder\ndef encoder(inputs):\n    c1 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(inputs)\n    c1 = tf.keras.layers.Dropout(0.1)(c1)\n    c1 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c1)\n    p1 = tf.keras.layers.MaxPooling2D((2, 2))(c1)\n\n    c2 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p1)\n    c2 = tf.keras.layers.Dropout(0.1)(c2)\n    c2 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c2)\n    p2 = tf.keras.layers.MaxPooling2D((2, 2))(c2)\n\n    c3 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p2)\n    c3 = tf.keras.layers.Dropout(0.2)(c3)\n    c3 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c3)\n    p3 = tf.keras.layers.MaxPooling2D((2, 2))(c3)\n\n    c4 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p3)\n    c4 = tf.keras.layers.Dropout(0.2)(c4)\n    c4 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c4)\n    p4 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(c4)\n\n    c5 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p4)\n    c5 = tf.keras.layers.Dropout(0.2)(c5)\n    c5 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c5)\n    p5 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(c5)\n\n    c6 = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p5)\n    c6 = tf.keras.layers.Dropout(0.3)(c6)\n    c6 = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c6)\n\n    u6 = tf.keras.layers.Conv2DTranspose(128, (2, 2), strides=(2, 2), padding='same')(c6)\n    c6 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(u6)\n    c6 = tf.keras.layers.Dropout(0.2)(c6)\n    c6 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c6)\n    return c6\n","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.034798Z","iopub.execute_input":"2023-01-09T17:44:32.035496Z","iopub.status.idle":"2023-01-09T17:44:32.065652Z","shell.execute_reply.started":"2023-01-09T17:44:32.03546Z","shell.execute_reply":"2023-01-09T17:44:32.064239Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Model decoder\ndef decoder(c6):\n    u7 = tf.keras.layers.Conv2DTranspose(64, (2, 2), strides=(2, 2), padding='same')(c6)\n    c7 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(u7)\n    c7 = tf.keras.layers.Add()([u7, c7])\n\n    u8 = tf.keras.layers.Conv2DTranspose(32, (2, 2), strides=(2, 2), padding='same')(c7)\n    c8 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(u8)\n    c8 = tf.keras.layers.Add()([u8, c8])\n\n    u9 = tf.keras.layers.Conv2DTranspose(16, (2, 2), strides=(2, 2), padding='same')(c8)\n    c9 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(u9)\n    c9 = tf.keras.layers.Add()([u9, c9])\n\n    u10 = tf.keras.layers.Conv2DTranspose(16, (2, 2), strides=(2, 2), padding='same')(c9)\n    c10 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(u10)\n    c10 = tf.keras.layers.Add()([u10, c10])\n\n    outputs = tf.keras.layers.Conv2D(num_classes, (1, 1), activation='sigmoid')(c10)\n    return outputs","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.071272Z","iopub.execute_input":"2023-01-09T17:44:32.072328Z","iopub.status.idle":"2023-01-09T17:44:32.082901Z","shell.execute_reply.started":"2023-01-09T17:44:32.072294Z","shell.execute_reply":"2023-01-09T17:44:32.081946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Adding relationship for input layer, encoder & decoder\nencoder = encoder(inputs)\noutputs = decoder(encoder)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.084652Z","iopub.execute_input":"2023-01-09T17:44:32.084946Z","iopub.status.idle":"2023-01-09T17:44:32.315365Z","shell.execute_reply.started":"2023-01-09T17:44:32.084922Z","shell.execute_reply":"2023-01-09T17:44:32.314436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Converting it to a model\nmodel = tf.keras.Model(inputs=[inputs], outputs=[outputs])","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.31661Z","iopub.execute_input":"2023-01-09T17:44:32.316959Z","iopub.status.idle":"2023-01-09T17:44:32.32945Z","shell.execute_reply.started":"2023-01-09T17:44:32.316926Z","shell.execute_reply":"2023-01-09T17:44:32.328439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Model structure\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.331569Z","iopub.execute_input":"2023-01-09T17:44:32.332476Z","iopub.status.idle":"2023-01-09T17:44:32.343313Z","shell.execute_reply.started":"2023-01-09T17:44:32.332439Z","shell.execute_reply":"2023-01-09T17:44:32.342379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Compiling the model with adam optimizer and binary cross entrophy loss\nmodel.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.344833Z","iopub.execute_input":"2023-01-09T17:44:32.345801Z","iopub.status.idle":"2023-01-09T17:44:32.355858Z","shell.execute_reply.started":"2023-01-09T17:44:32.345763Z","shell.execute_reply":"2023-01-09T17:44:32.35474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Setting up callbacks\ncallbacks = [\n        tf.keras.callbacks.EarlyStopping(patience=15, monitor='val_loss'),\n        tf.keras.callbacks.TensorBoard(log_dir='logs')]","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.357632Z","iopub.execute_input":"2023-01-09T17:44:32.358196Z","iopub.status.idle":"2023-01-09T17:44:32.900744Z","shell.execute_reply.started":"2023-01-09T17:44:32.358103Z","shell.execute_reply":"2023-01-09T17:44:32.899729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Fitting the data in the model\nmodel.fit(X_train, y_train, validation_data=(X_test,y_test), batch_size=16, epochs=100, callbacks=callbacks)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:44:32.90252Z","iopub.execute_input":"2023-01-09T17:44:32.90341Z","iopub.status.idle":"2023-01-09T17:45:30.021686Z","shell.execute_reply.started":"2023-01-09T17:44:32.903368Z","shell.execute_reply":"2023-01-09T17:45:30.020663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Loss plot for train & test data\nloss = model.history.history['loss']\nval_loss = model.history.history['val_loss']\nplt.figure()\nplt.plot( loss, 'r', label='Training loss')\nplt.plot( val_loss, 'bo', label='Validation loss')\nplt.title('Training and Validation Loss')\nplt.xlabel('Epoch')\nplt.ylabel('Loss Value')\nplt.ylim([0, 1])\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:45:30.023329Z","iopub.execute_input":"2023-01-09T17:45:30.023696Z","iopub.status.idle":"2023-01-09T17:45:30.227662Z","shell.execute_reply.started":"2023-01-09T17:45:30.02366Z","shell.execute_reply":"2023-01-09T17:45:30.226637Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Model Predictions</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"code","source":"# Predicting for a random model\ni = random.randint(0, len(X_test))\nsample_image = X_test[i]\nsample_mask = y_test[i]\npredictions = model.predict(X_test)\nprediction = model.predict(sample_image[tf.newaxis, ...])[0]\npredicted_mask = (prediction > 0.5).astype(np.uint8)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:46:00.164172Z","iopub.execute_input":"2023-01-09T17:46:00.164539Z","iopub.status.idle":"2023-01-09T17:46:00.394196Z","shell.execute_reply.started":"2023-01-09T17:46:00.164506Z","shell.execute_reply":"2023-01-09T17:46:00.393222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Comparing oringinal mask and the predictions\nplt.figure(figsize=(15, 15))\ntitle = ['Input image', 'True mask', 'Predicted mask']\ndisplay_list = [sample_image, sample_mask,predicted_mask]\nfor 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')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T17:46:00.692874Z","iopub.execute_input":"2023-01-09T17:46:00.693797Z","iopub.status.idle":"2023-01-09T17:46:00.956709Z","shell.execute_reply.started":"2023-01-09T17:46:00.693746Z","shell.execute_reply":"2023-01-09T17:46:00.955756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 5>Comparing different notebooks</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Notebook 1</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"markdown","source":"### Notebook URL - https://www.kaggle.com/code/ramsegaurav/unet-for-image-segmentation\n\n### Results\n<img src = \"https://gcdnb.pbrd.co/images/UHyfGhQEUtUw.png?o=1\">\n<img src = \"https://iili.io/H7oOVM7.png\">","metadata":{}},{"cell_type":"markdown","source":"#### After analysing the notebook, I got to know that he/she has implemented UNet with <b>adam optimizer</b>, loss function as <b>binary_crossentropy</b> and <b>100 epochs</b>. As U-Net is specifically designed for Biomedical Image Segmentation, it worked better than the FCNN model which I tried on the data. \n#### Validation Loss - 0.15\n#### Validation Accuracy - 0.92 ","metadata":{}},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Notebook 2</font></h4>\n    </strong>\n</div>","metadata":{"execution":{"iopub.status.busy":"2023-01-09T18:00:16.808399Z","iopub.execute_input":"2023-01-09T18:00:16.808953Z","iopub.status.idle":"2023-01-09T18:00:16.81799Z","shell.execute_reply.started":"2023-01-09T18:00:16.808904Z","shell.execute_reply":"2023-01-09T18:00:16.816542Z"}}},{"cell_type":"markdown","source":"### Notebook URL - https://www.kaggle.com/code/kmader/keras-linknet\n\n### Results\n<img src = \"https://gcdnb.pbrd.co/images/koaFLFdjmAR1.png?o=1\">\n\n\n#### The success of LinkNet for Carvana and presentation by Vladimir Iglovikov made the author think it might be worth a try for segmenting nuclei. The architecture used is the so-called LinkNet, which is very common for image segmentation problems such as this. They also have a tendency to work quite well even on small datasets.\n\n#### val_loss: 0.4572\n#### val_binary_crossentropy: 0.1866\n#### val_dice_coef: 0.7770\n#### val_mean_iou: 0.7819\n","metadata":{}},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Notebook 3</font></h4>\n    </strong>\n</div>","metadata":{}},{"cell_type":"markdown","source":"### Notebook URL - https://www.kaggle.com/code/mosnoiion/u-net-vgg16-open-for-team-merge-lb-0-319\n\n<img src = \"https://gcdnb.pbrd.co/images/FktTH6hZmlGP.png?o=1\">\n\n\nIn this notebook, I analysed that he has merged VGG 16 model already trained weights to the UNet for better segmentation and it worked very well than normal Unet model and the predictions are done more precisely\n\n#### val_loss: 0.0765 \n#### val_mean_iou: 0.3846\n\n","metadata":{}},{"cell_type":"markdown","source":"<div style=\"background:#c72e57;color:#fff;padding:1em 2em 1.5em 2em;border-radius: 3px;font-weight:bold\">\n    <strong>\n        <h4 style = \"color:#fff\"><font size = 4>Notebook 4</font></h4>\n    </strong>\n</div>","metadata":{"execution":{"iopub.status.busy":"2023-01-09T18:34:58.355635Z","iopub.execute_input":"2023-01-09T18:34:58.356449Z","iopub.status.idle":"2023-01-09T18:34:58.365059Z","shell.execute_reply.started":"2023-01-09T18:34:58.356413Z","shell.execute_reply":"2023-01-09T18:34:58.363597Z"}}},{"cell_type":"markdown","source":"### Notebook URL - https://www.kaggle.com/code/kmader/optimizing-ali-s-segmentation\n\n<img src = \"https://gcdnb.pbrd.co/images/SPOGYHMw2XLi.png?o=1\">\n\n\nThe idea in the notebook was to take the parameters found in the top kernels and try to improve them using the IOU score as the ground criteria.\n\n1. Get a cross-validation setup working that gives us a similar value to the 0.274\n2. Rewrite the threshold and label methods to take all of their parameters\n3. Use scipy.optimize (probably sk-optimize would be better, but we'll keep it simple here) to improve the values\n\n#### val_loss : 0.13672\n#### val_mean_iou: 0.420544519338\n\n","metadata":{}}]}