## Initial setup

```python
from google.colab import drive
drive.mount('/content/drive')
```

    Mounted at /content/drive

```python
import tensorflow as tf
print(tf.__version__)
import torch
print(torch.__version__)
import matplotlib
print(matplotlib.__version__)
```

    2.8.0
    1.10.0+cu111
    3.2.2

```python
!nvidia-smi
```

    Fri Jan 21 19:41:32 2022
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 495.46       Driver Version: 460.32.03    CUDA Version: 11.2     |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |                               |                      |               MIG M. |
    |===============================+======================+======================|
    |   0  Tesla T4            Off  | 00000000:00:04.0 Off |                    0 |
    | N/A   34C    P8     9W /  70W |      0MiB / 15109MiB |      0%      Default |
    |                               |                      |                  N/A |
    +-------------------------------+----------------------+----------------------+

    +-----------------------------------------------------------------------------+
    | Processes:                                                                  |
    |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
    |        ID   ID                                                   Usage      |
    |=============================================================================|
    |  No running processes found                                                 |
    +-----------------------------------------------------------------------------+

```python
# Other imports
! pip install tensorflow_addons
! pip install tensorflow_io

import os
from tensorflow.keras.layers import *
from tensorflow.keras.models import *
from keras.callbacks import Callback, EarlyStopping, ModelCheckpoint
from tensorflow.keras.applications.resnet50 import preprocess_input
from tensorflow.keras.preprocessing.image import load_img

import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
from matplotlib.ticker import MultipleLocator, FormatStrFormatter, AutoMinorLocator
from imutils import paths
from tqdm import tqdm
import tensorflow as tf
import tensorflow_addons as tfa
import tensorflow_datasets as tfds
import tensorflow_io as tfio
import tensorflow_hub as hub
import numpy as np
import cv2
import pandas as pd
import seaborn as sns
from scipy.stats import mannwhitneyu
from sklearn.preprocessing import LabelEncoder
from sklearn.cluster import KMeans
import sklearn.manifold
from sklearn.metrics.pairwise import cosine_similarity as cos
from sympy.utilities.iterables import multiset_permutations
from sklearn.metrics import accuracy_score, f1_score,precision_score, recall_score, roc_auc_score, confusion_matrix
from sklearn.model_selection import *
from sklearn.preprocessing import StandardScaler
from IPython.display import Image, display

import zipfile
import concurrent.futures

# Random seed fix
random_seed = 42
tf.random.set_seed(random_seed)
np.random.seed(random_seed)
```

    Collecting tensorflow_addons
      Downloading tensorflow_addons-0.16.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.1 MB)
         |████████████████████████████████| 1.1 MB 6.4 MB/s
    Requirement already satisfied: typeguard>=2.7 in /usr/local/lib/python3.7/dist-packages (from tensorflow_addons) (2.7.1)
    Installing collected packages: tensorflow-addons
    Successfully installed tensorflow-addons-0.16.1
    Collecting tensorflow_io
      Downloading tensorflow_io-0.24.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (23.4 MB)
         |████████████████████████████████| 23.4 MB 1.8 MB/s
    Requirement already satisfied: tensorflow-io-gcs-filesystem==0.24.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow_io) (0.24.0)
    Installing collected packages: tensorflow-io
    Successfully installed tensorflow-io-0.24.0

## Dataset gathering and preparation

```python
%cd /content/drive/MyDrive/nanowire-morphology-classification-project
```

```python
training_batch_size = 4

BATCH_SIZE = training_batch_size

imageSize = 224

category_names = ['bundle', 'dispersed', 'network', 'singular']
color_method = ['C0', 'C1', 'C2', 'C3', 'C4']
color = ['black', 'magenta', 'cyan', 'yellow']
marker = ['o', 's', '<', '>', '^']
seaborn_palette = sns.color_palette("colorblind")
```

```python
# Image preprocessing utils
@tf.function
def parse_images(image_path):
    image_string = tf.io.read_file(image_path)
    image = tf.image.decode_jpeg(image_string, channels=3)
    # image = tfio.experimental.image.decode_tiff(image_string)[:, :, :3]   # in the doc, it transforms tiff to 4 channels, with additional channel of opacity which is not needed.
    image = tf.image.convert_image_dtype(image, tf.float32)
    image = tf.image.resize(image, size=[imageSize, imageSize])

    return image
```

## Initiate self-supervised models

```python
Resnet50_transfer = tf.keras.applications.ResNet50(
    include_top=False,
    weights="imagenet",
    input_tensor=None,
    input_shape=(imageSize, imageSize, 3),
    pooling=None,
)

Resnet50_transfer.trainable = False
```

    Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/resnet/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5
    94773248/94765736 [==============================] - 1s 0us/step
    94781440/94765736 [==============================] - 1s 0us/step

```python
# Resnet as backbone
def get_resnet_self_supervise_model(hidden_1, hidden_2, hidden_3):
    base_model = Resnet50_transfer
    base_model.trainable = True
    inputs = Input((imageSize, imageSize, 3))
    h = base_model(inputs, training=True)
    h = GlobalAveragePooling2D()(h)

    projection_1 = Dense(hidden_1)(h)
    projection_1 = Activation("relu")(projection_1)
    projection_1 = BatchNormalization(epsilon=0.001)(projection_1)
    projection_2 = Dense(hidden_2)(projection_1)
    projection_2 = Activation("relu")(projection_2)
    projection_2 = BatchNormalization(epsilon=0.001)(projection_2)
    projection_3 = Dense(hidden_3)(projection_2)
    projection_3 = BatchNormalization(epsilon=0.001)(projection_3)

    resnet_model = Model(inputs, projection_3)

    return resnet_model
```

## segmentation data preparation, model and results

```python
np.random.seed(random_seed)
peptide_morph_seglabel_train_path = "/content/drive/MyDrive/TEM image datasets/2022-nanowire-morphology"
peptide_morph_images_train_seglabel = list(paths.list_files(basePath=peptide_morph_seglabel_train_path, validExts='png'))
peptide_morph_images_train_seglabel = np.random.choice(np.array(peptide_morph_images_train_seglabel), len(peptide_morph_images_train_seglabel), replace=False)
print(len(peptide_morph_images_train_seglabel))
```

    200

```python
def generate_ground_truth_images(image, resolution):
  image_bool = np.ones((resolution, resolution))
  for i in range(image.shape[0]):
    for j in range(image.shape[1]):
      if image[i, j, 1] == image[i, j, 2]:
        image_bool[i, j] = 0            # background is black with code of 0
      else:
        image_bool[i, j] = 1            # nanowire is white with code of 1
  return image_bool
```

```python
segmentation_class_labels = []
for i in range(peptide_morph_images_train_seglabel.shape[0]):
  seg_class_label = peptide_morph_images_train_seglabel[i].split("/")[-2]
  segmentation_class_labels.append(seg_class_label)
le = LabelEncoder()
peptide_morph_train_seg_enc = le.fit_transform(segmentation_class_labels)
```

```python
# image_mask = np.zeros((len(peptide_morph_images_train_seglabel), imageSize, imageSize))
images_no_annotation_directory = []
images_no_annotation = np.zeros((len(peptide_morph_images_train_seglabel), imageSize, imageSize, 3))

for i in range(len(peptide_morph_images_train_seglabel)):
  images_no_annotation_directory.append('%s.jpg' % (peptide_morph_images_train_seglabel[i].split("_")[0] + "_" + peptide_morph_images_train_seglabel[i].split("_")[1]))
  images_no_annotation[i] = parse_images(images_no_annotation_directory[i])

  # these were used to create the ground truth grayscale images from the manual segmentation labels.
  # image_string = tf.io.read_file(peptide_morph_images_train_seglabel[i])
  # image = tf.image.decode_image(image_string, channels=3) / 255
  # image = tf.image.resize(image, (imageSize, imageSize))
  # image = tf.image.convert_image_dtype(image, tf.float32)
  # trans_nd_image_array = image.numpy()
  # image_mask[i] = generate_ground_truth_images(trans_nd_image_array, imageSize)

# np.savez_compressed('seg_mask_res512.npz', mask=image_mask)

# once we have the seg_mask saved, we can directly load from npz file
image_mask = np.load('seg_mask_res%i.npz' % (imageSize), allow_pickle=True)['mask']
```

    WARNING:tensorflow:5 out of the last 5 calls to <function parse_images at 0x7f9490054b90> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for  more details.
    WARNING:tensorflow:6 out of the last 6 calls to <function parse_images at 0x7f9490054b90> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for  more details.

```python
def upsample(filters, size, apply_dropout=False):

  result = Sequential()
  result.add(
    Conv2DTranspose(filters, size, strides=2,
                                    padding='same',
                                    kernel_initializer='he_uniform',
                                    use_bias=False))

  result.add(BatchNormalization())

  if apply_dropout:
      result.add(Dropout(0.5))

  result.add(ReLU())

  return result
```

```python
# build our resnet50-unet model with the option of transfered weights from either tem images
def unet_model(base_model, resolution):
  inputs = tf.keras.layers.Input(shape=[resolution, resolution, 3])

  # Use the activations of these layers
  layer_names = [
      'conv1_relu',         # (batch_size, 112, 112, 64)
      'conv2_block3_out',   # (batch_size, 56, 56, 256)
      'conv3_block4_out',   # (batch_size, 28, 28, 512)
      'conv4_block6_out',   # (batch_size, 14, 14, 1024)
      'conv5_block3_out'    # (batch_size, 7, 7, 2048)
  ]
  base_model_outputs = [base_model.get_layer(name).output for name in layer_names]

  # Create the feature extraction model
  encoder = Model(inputs=base_model.input, outputs=base_model_outputs)

  encoder.trainable = False

  decoder = [
    upsample(1024, 4),  # (batch_size, 7, 7, 2048)
    upsample(512, 4),  # (batch_size, 14, 14, 1024)
    upsample(256, 4),  # (batch_size, 28, 28, 512)
    upsample(128, 4),  # (batch_size, 56, 56, 256)
  ]

  last = Conv2DTranspose(1, 4,    # number of class, size of input vector (batch_size, x, y, class)
                              strides=2,
                              padding='same',
                              use_bias=True,
                              kernel_initializer='he_uniform',
                              activation='sigmoid')       # (batch_size, resolution, resolution, 3)

  # Downsampling through the model
  skips = encoder(inputs)
  x = skips[-1]
  skips = reversed(skips[:-1])        # exclude the last conv layer, reverse is a python native function

  # Upsampling and establishing the skip connections
  for up, skip in zip(decoder, skips):
    x = up(x)
    x = Concatenate()([x, skip])

  x = last(x)

  return tf.keras.Model(inputs=inputs, outputs=x)
```

```python
# define loss functions and metrics for segmentation task
# coef functions are for batches of images, score functions are for a single image

def dice_coef(y_true, y_pred, smooth=0.000001):

    beta = 1
    tp = tf.reduce_sum(y_true * y_pred, axis=[1,2])
    fp = tf.reduce_sum(y_pred, axis=[1,2]) - tp
    fn = tf.reduce_sum(y_true, axis=[1,2]) - tp

    score = tf.reduce_mean(((1 + beta ** 2) * tp + smooth) \
            / ((1 + beta ** 2) * tp + beta ** 2 * fn + fp + smooth))
    return score

def dice_score(y_true, y_pred, smooth=0.000001):
  y_true = y_true.astype('float32')
  beta = 1
  tp = tf.reduce_sum(y_true * y_pred, axis=[1])
  fp = tf.reduce_sum(y_pred, axis=[1]) - tp
  fn = tf.reduce_sum(y_true, axis=[1]) - tp

  score = tf.reduce_mean(((1 + beta ** 2) * tp + smooth) \
          / ((1 + beta ** 2) * tp + beta ** 2 * fn + fp + smooth)).numpy()
  return score

def dice_coef_loss(y_true, y_pred):
    return 1 - dice_coef(y_true, y_pred)

def iou_coef(y_true, y_pred, smooth=0.000001):

    beta = 1
    tp = tf.reduce_sum(y_true * y_pred, axis=[1,2])
    fp = tf.reduce_sum(y_pred, axis=[1,2]) - tp
    fn = tf.reduce_sum(y_true, axis=[1,2]) - tp

    score = tf.reduce_mean((tp + smooth) \
            / (tp + fn + fp + smooth))
    return score

def iou_score(y_true, y_pred, smooth=0.000001):
  y_true = y_true.astype('float32')
  tp = tf.reduce_sum(y_true * y_pred, axis=[1])
  fp = tf.reduce_sum(y_pred, axis=[1]) - tp
  fn = tf.reduce_sum(y_true, axis=[1]) - tp

  score = tf.reduce_mean((tp + smooth) \
          / (tp + fn + fp + smooth)).numpy()
  return score

def iou_coef_loss(y_true, y_pred):
    return 1 - iou_coef(y_true, y_pred)
```

```python
tf.random.set_seed(random_seed)

encoder_res = np.array([224, 384, 224])
encoder_batch_size = np.array([64, 16, 64])
random_seed_list = np.array([45])
# random_seed_for_split = np.linspace(42, 42 + 3, 4).astype(int)
random_seed_for_split = np.array([42])
training_image_size = np.array([80, 32, 16, 8, 4, 2, 1])
n_epoch = np.array([20, 30, 40, 60, 120, 120, 120])

for i in range(len(random_seed_list)):
  resnet_model = get_resnet_self_supervise_model(128, 64, 1024)
  if encoder_res[0] == 224:
    resnet_model.load_weights('barlow_resnet_batch%i_project128_64_1024_seed%i.h5' % (encoder_batch_size[0], random_seed_list[i]))
  else:
    resnet_model.load_weights('barlow_resnet_batch%i_project128_64_1024_res%i_seed%i.h5' % (encoder_batch_size[0], encoder_res[0], random_seed_list[i]))
  trained_resnet50 = resnet_model.get_layer('resnet50')

  for j in range(len(random_seed_for_split)):
    seg_scores = np.zeros((len(training_image_size), int(image_mask.shape[0] / 5), 2))

    X_TRAIN, x_val, MASK_TRAIN, mask_val = train_test_split(images_no_annotation, image_mask, test_size=0.2, shuffle=True, stratify=peptide_morph_train_seg_enc, random_state=random_seed_for_split[j])
    X_TRAIN, x_val, TRAIN_FILENAME, test_filename = train_test_split(images_no_annotation, peptide_morph_images_train_seglabel, test_size=0.2, shuffle=True, stratify=peptide_morph_train_seg_enc, random_state=random_seed_for_split[j])
    X_TRAIN, x_val, seg_class_train, seg_class_val = train_test_split(images_no_annotation, peptide_morph_train_seg_enc, test_size=0.2, shuffle=True, stratify=peptide_morph_train_seg_enc, random_state=random_seed_for_split[j])

    for n in range(len(training_image_size)):
      if os.path.isdir('segmentation_figures/res%i_enc_res%i_seed%i_seed%i_datasize%i' %(imageSize, encoder_res[0], random_seed_list[i], random_seed_for_split[j], training_image_size[n])) != True:
        os.mkdir('segmentation_figures/res%i_enc_res%i_seed%i_seed%i_datasize%i' %(imageSize, encoder_res[0], random_seed_list[i], random_seed_for_split[j], training_image_size[n]))

      if training_image_size[n] != 80:
        x_train, x_no_val, mask_train, mask_no_val = train_test_split(X_TRAIN, MASK_TRAIN, test_size=(1 - training_image_size[n] * 2 / len(seg_class_train)), shuffle=True, stratify=seg_class_train, random_state=42)
        x_train, x_no_val, train_filename, filename_no_val = train_test_split(X_TRAIN, TRAIN_FILENAME, test_size=(1 - training_image_size[n] * 2 / len(seg_class_train)), shuffle=True, stratify=seg_class_train, random_state=42)
      else:
        x_train = X_TRAIN
        mask_train = MASK_TRAIN

      # train segmentation model
      unet = unet_model(trained_resnet50, imageSize)
      unet.compile(optimizer='adam',
                    loss=dice_coef_loss,
                    metrics=[iou_coef, dice_coef])
      model_history = unet.fit(x=x_train, y=mask_train, epochs=n_epoch[n],
                                batch_size=training_batch_size,
                                validation_data=(x_val, mask_val)
                                )
      # log best segmentation model performance
      y_predict = unet.predict(x_val, batch_size=training_batch_size)
      y_predict = y_predict.reshape((len(x_val), imageSize, imageSize))

      filename = []
      for k in range(y_predict.shape[0]):
        filename.append(test_filename[k].split("/")[-1])
        seg_scores[n, k, 0] = iou_score(mask_val[k], y_predict[k])
        seg_scores[n, k, 1] = dice_score(mask_val[k], y_predict[k])
        fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(20,20))
        ax1.imshow(x_val[k])
        nanowire_pix = np.transpose(np.vstack((np.where(mask_val[k] == 0)[0], np.where(mask_val[k] == 0)[1])))
        image_a = np.expand_dims(mask_val[k], axis=-1) * np.array([1, 1, 1])
        ax2.imshow(image_a)
        nanowire_pix = np.transpose(np.vstack((np.where(y_predict[k] == 0)[0], np.where(y_predict[k] == 0)[1])))
        image_a = np.expand_dims(y_predict[k], axis=-1) * np.array([1, 1, 1])
        ax3.imshow(image_a)
        plt.title('iou: %1.4f dice: %1.4f' % (seg_scores[n, k, 0], seg_scores[n, k, 1]))
        plt.savefig('segmentation_figures/res%i_enc_res%i_seed%i_seed%i_datasize%i/%s' %(imageSize, encoder_res[0], random_seed_list[i], random_seed_for_split[j], training_image_size[n], test_filename[k].split("/")[-1]))
        plt.close('all')

    np.savez_compressed('segmentation_scores_main_result/res%i_enc_res%i_seed%i_seed%i.npz' %(imageSize, encoder_res[0], random_seed_list[i], random_seed_for_split[j]), scores=seg_scores, filename=filename)
```

    Epoch 1/20
    40/40 [==============================] - 18s 343ms/step - loss: 0.5349 - iou_coef: 0.3158 - dice_coef: 0.4651 - val_loss: 0.6011 - val_iou_coef: 0.2629 - val_dice_coef: 0.3989
    Epoch 2/20
    40/40 [==============================] - 12s 305ms/step - loss: 0.4216 - iou_coef: 0.4197 - dice_coef: 0.5784 - val_loss: 0.5148 - val_iou_coef: 0.3338 - val_dice_coef: 0.4852
    Epoch 3/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.3387 - iou_coef: 0.5071 - dice_coef: 0.6613 - val_loss: 0.5365 - val_iou_coef: 0.3160 - val_dice_coef: 0.4635
    Epoch 4/20
    40/40 [==============================] - 12s 307ms/step - loss: 0.2714 - iou_coef: 0.5817 - dice_coef: 0.7286 - val_loss: 0.5199 - val_iou_coef: 0.3307 - val_dice_coef: 0.4801
    Epoch 5/20
    40/40 [==============================] - 12s 307ms/step - loss: 0.2524 - iou_coef: 0.6036 - dice_coef: 0.7476 - val_loss: 0.3672 - val_iou_coef: 0.4770 - val_dice_coef: 0.6328
    Epoch 6/20
    40/40 [==============================] - 12s 307ms/step - loss: 0.2466 - iou_coef: 0.6123 - dice_coef: 0.7534 - val_loss: 0.2769 - val_iou_coef: 0.5749 - val_dice_coef: 0.7231
    Epoch 7/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2387 - iou_coef: 0.6218 - dice_coef: 0.7613 - val_loss: 0.2393 - val_iou_coef: 0.6214 - val_dice_coef: 0.7607
    Epoch 8/20
    40/40 [==============================] - 12s 307ms/step - loss: 0.2366 - iou_coef: 0.6237 - dice_coef: 0.7634 - val_loss: 0.2506 - val_iou_coef: 0.6070 - val_dice_coef: 0.7494
    Epoch 9/20
    40/40 [==============================] - 12s 307ms/step - loss: 0.2292 - iou_coef: 0.6335 - dice_coef: 0.7708 - val_loss: 0.2347 - val_iou_coef: 0.6276 - val_dice_coef: 0.7653
    Epoch 10/20
    40/40 [==============================] - 12s 307ms/step - loss: 0.2356 - iou_coef: 0.6254 - dice_coef: 0.7644 - val_loss: 0.2428 - val_iou_coef: 0.6166 - val_dice_coef: 0.7572
    Epoch 11/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2324 - iou_coef: 0.6306 - dice_coef: 0.7676 - val_loss: 0.2303 - val_iou_coef: 0.6334 - val_dice_coef: 0.7697
    Epoch 12/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2189 - iou_coef: 0.6459 - dice_coef: 0.7811 - val_loss: 0.2283 - val_iou_coef: 0.6358 - val_dice_coef: 0.7717
    Epoch 13/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2178 - iou_coef: 0.6480 - dice_coef: 0.7822 - val_loss: 0.2269 - val_iou_coef: 0.6382 - val_dice_coef: 0.7731
    Epoch 14/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2213 - iou_coef: 0.6442 - dice_coef: 0.7787 - val_loss: 0.2288 - val_iou_coef: 0.6354 - val_dice_coef: 0.7712
    Epoch 15/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2264 - iou_coef: 0.6383 - dice_coef: 0.7736 - val_loss: 0.2659 - val_iou_coef: 0.5871 - val_dice_coef: 0.7341
    Epoch 16/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2249 - iou_coef: 0.6392 - dice_coef: 0.7751 - val_loss: 0.2308 - val_iou_coef: 0.6319 - val_dice_coef: 0.7692
    Epoch 17/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2157 - iou_coef: 0.6512 - dice_coef: 0.7843 - val_loss: 0.2463 - val_iou_coef: 0.6144 - val_dice_coef: 0.7537
    Epoch 18/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2148 - iou_coef: 0.6517 - dice_coef: 0.7852 - val_loss: 0.2269 - val_iou_coef: 0.6383 - val_dice_coef: 0.7731
    Epoch 19/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2151 - iou_coef: 0.6514 - dice_coef: 0.7849 - val_loss: 0.2219 - val_iou_coef: 0.6444 - val_dice_coef: 0.7781
    Epoch 20/20
    40/40 [==============================] - 12s 306ms/step - loss: 0.2163 - iou_coef: 0.6498 - dice_coef: 0.7837 - val_loss: 0.2280 - val_iou_coef: 0.6366 - val_dice_coef: 0.7720
    Epoch 1/30
    16/16 [==============================] - 11s 456ms/step - loss: 0.4852 - iou_coef: 0.3647 - dice_coef: 0.5148 - val_loss: 0.6001 - val_iou_coef: 0.2662 - val_dice_coef: 0.3999
    Epoch 2/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.3791 - iou_coef: 0.4641 - dice_coef: 0.6209 - val_loss: 0.6000 - val_iou_coef: 0.2663 - val_dice_coef: 0.4000
    Epoch 3/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.3423 - iou_coef: 0.5010 - dice_coef: 0.6577 - val_loss: 0.5623 - val_iou_coef: 0.2983 - val_dice_coef: 0.4377
    Epoch 4/30
    16/16 [==============================] - 6s 358ms/step - loss: 0.3089 - iou_coef: 0.5395 - dice_coef: 0.6911 - val_loss: 0.5591 - val_iou_coef: 0.2993 - val_dice_coef: 0.4409
    Epoch 5/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2743 - iou_coef: 0.5768 - dice_coef: 0.7257 - val_loss: 0.5915 - val_iou_coef: 0.2726 - val_dice_coef: 0.4085
    Epoch 6/30
    16/16 [==============================] - 6s 358ms/step - loss: 0.2628 - iou_coef: 0.5897 - dice_coef: 0.7372 - val_loss: 0.5907 - val_iou_coef: 0.2729 - val_dice_coef: 0.4093
    Epoch 7/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.2647 - iou_coef: 0.5886 - dice_coef: 0.7353 - val_loss: 0.5534 - val_iou_coef: 0.3014 - val_dice_coef: 0.4466
    Epoch 8/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2538 - iou_coef: 0.6020 - dice_coef: 0.7462 - val_loss: 0.3743 - val_iou_coef: 0.4680 - val_dice_coef: 0.6257
    Epoch 9/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.2472 - iou_coef: 0.6118 - dice_coef: 0.7528 - val_loss: 0.3810 - val_iou_coef: 0.4595 - val_dice_coef: 0.6190
    Epoch 10/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2513 - iou_coef: 0.6056 - dice_coef: 0.7487 - val_loss: 0.2697 - val_iou_coef: 0.5883 - val_dice_coef: 0.7303
    Epoch 11/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.2420 - iou_coef: 0.6149 - dice_coef: 0.7580 - val_loss: 0.2680 - val_iou_coef: 0.5849 - val_dice_coef: 0.7320
    Epoch 12/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2334 - iou_coef: 0.6279 - dice_coef: 0.7666 - val_loss: 0.2927 - val_iou_coef: 0.5540 - val_dice_coef: 0.7073
    Epoch 13/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2345 - iou_coef: 0.6254 - dice_coef: 0.7655 - val_loss: 0.3896 - val_iou_coef: 0.4498 - val_dice_coef: 0.6104
    Epoch 14/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2329 - iou_coef: 0.6290 - dice_coef: 0.7671 - val_loss: 0.3420 - val_iou_coef: 0.4969 - val_dice_coef: 0.6580
    Epoch 15/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2387 - iou_coef: 0.6200 - dice_coef: 0.7613 - val_loss: 0.3658 - val_iou_coef: 0.4753 - val_dice_coef: 0.6342
    Epoch 16/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2235 - iou_coef: 0.6398 - dice_coef: 0.7765 - val_loss: 0.2685 - val_iou_coef: 0.5850 - val_dice_coef: 0.7315
    Epoch 17/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2204 - iou_coef: 0.6436 - dice_coef: 0.7796 - val_loss: 0.2407 - val_iou_coef: 0.6206 - val_dice_coef: 0.7593
    Epoch 18/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2273 - iou_coef: 0.6343 - dice_coef: 0.7727 - val_loss: 0.2822 - val_iou_coef: 0.5747 - val_dice_coef: 0.7178
    Epoch 19/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.2183 - iou_coef: 0.6467 - dice_coef: 0.7817 - val_loss: 0.2407 - val_iou_coef: 0.6211 - val_dice_coef: 0.7593
    Epoch 20/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2171 - iou_coef: 0.6477 - dice_coef: 0.7829 - val_loss: 0.2360 - val_iou_coef: 0.6266 - val_dice_coef: 0.7640
    Epoch 21/30
    16/16 [==============================] - 6s 358ms/step - loss: 0.2326 - iou_coef: 0.6298 - dice_coef: 0.7674 - val_loss: 0.3109 - val_iou_coef: 0.5314 - val_dice_coef: 0.6891
    Epoch 22/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2262 - iou_coef: 0.6371 - dice_coef: 0.7738 - val_loss: 0.2488 - val_iou_coef: 0.6091 - val_dice_coef: 0.7512
    Epoch 23/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.2281 - iou_coef: 0.6350 - dice_coef: 0.7719 - val_loss: 0.3441 - val_iou_coef: 0.4983 - val_dice_coef: 0.6559
    Epoch 24/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2133 - iou_coef: 0.6533 - dice_coef: 0.7867 - val_loss: 0.2467 - val_iou_coef: 0.6122 - val_dice_coef: 0.7533
    Epoch 25/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2141 - iou_coef: 0.6527 - dice_coef: 0.7859 - val_loss: 0.2388 - val_iou_coef: 0.6228 - val_dice_coef: 0.7612
    Epoch 26/30
    16/16 [==============================] - 6s 358ms/step - loss: 0.2119 - iou_coef: 0.6549 - dice_coef: 0.7881 - val_loss: 0.2408 - val_iou_coef: 0.6202 - val_dice_coef: 0.7592
    Epoch 27/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.1971 - iou_coef: 0.6743 - dice_coef: 0.8029 - val_loss: 0.2382 - val_iou_coef: 0.6234 - val_dice_coef: 0.7618
    Epoch 28/30
    16/16 [==============================] - 6s 356ms/step - loss: 0.2002 - iou_coef: 0.6710 - dice_coef: 0.7998 - val_loss: 0.2804 - val_iou_coef: 0.5731 - val_dice_coef: 0.7196
    Epoch 29/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2151 - iou_coef: 0.6501 - dice_coef: 0.7849 - val_loss: 0.2519 - val_iou_coef: 0.6070 - val_dice_coef: 0.7481
    Epoch 30/30
    16/16 [==============================] - 6s 357ms/step - loss: 0.2120 - iou_coef: 0.6554 - dice_coef: 0.7880 - val_loss: 0.2359 - val_iou_coef: 0.6262 - val_dice_coef: 0.7641
    Epoch 1/40
    8/8 [==============================] - 9s 657ms/step - loss: 0.5749 - iou_coef: 0.2826 - dice_coef: 0.4251 - val_loss: 0.6103 - val_iou_coef: 0.2566 - val_dice_coef: 0.3897
    Epoch 2/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.5082 - iou_coef: 0.3386 - dice_coef: 0.4918 - val_loss: 0.6064 - val_iou_coef: 0.2603 - val_dice_coef: 0.3936
    Epoch 3/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.4825 - iou_coef: 0.3619 - dice_coef: 0.5175 - val_loss: 0.6064 - val_iou_coef: 0.2603 - val_dice_coef: 0.3936
    Epoch 4/40
    8/8 [==============================] - 3s 451ms/step - loss: 0.4653 - iou_coef: 0.3779 - dice_coef: 0.5347 - val_loss: 0.6063 - val_iou_coef: 0.2604 - val_dice_coef: 0.3937
    Epoch 5/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.4398 - iou_coef: 0.4008 - dice_coef: 0.5602 - val_loss: 0.6037 - val_iou_coef: 0.2626 - val_dice_coef: 0.3963
    Epoch 6/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.4118 - iou_coef: 0.4277 - dice_coef: 0.5882 - val_loss: 0.6004 - val_iou_coef: 0.2649 - val_dice_coef: 0.3996
    Epoch 7/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.3778 - iou_coef: 0.4611 - dice_coef: 0.6222 - val_loss: 0.5941 - val_iou_coef: 0.2710 - val_dice_coef: 0.4059
    Epoch 8/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.3216 - iou_coef: 0.5228 - dice_coef: 0.6784 - val_loss: 0.5658 - val_iou_coef: 0.2944 - val_dice_coef: 0.4342
    Epoch 9/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.2633 - iou_coef: 0.5885 - dice_coef: 0.7367 - val_loss: 0.5164 - val_iou_coef: 0.3389 - val_dice_coef: 0.4836
    Epoch 10/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.2611 - iou_coef: 0.5909 - dice_coef: 0.7389 - val_loss: 0.4703 - val_iou_coef: 0.3727 - val_dice_coef: 0.5297
    Epoch 11/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.2438 - iou_coef: 0.6144 - dice_coef: 0.7562 - val_loss: 0.4863 - val_iou_coef: 0.3563 - val_dice_coef: 0.5137
    Epoch 12/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.2292 - iou_coef: 0.6311 - dice_coef: 0.7708 - val_loss: 0.3317 - val_iou_coef: 0.5170 - val_dice_coef: 0.6683
    Epoch 13/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.2300 - iou_coef: 0.6299 - dice_coef: 0.7700 - val_loss: 0.3637 - val_iou_coef: 0.4753 - val_dice_coef: 0.6363
    Epoch 14/40
    8/8 [==============================] - 3s 454ms/step - loss: 0.2191 - iou_coef: 0.6443 - dice_coef: 0.7809 - val_loss: 0.3810 - val_iou_coef: 0.4598 - val_dice_coef: 0.6190
    Epoch 15/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.2082 - iou_coef: 0.6590 - dice_coef: 0.7918 - val_loss: 0.2986 - val_iou_coef: 0.5494 - val_dice_coef: 0.7014
    Epoch 16/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.2144 - iou_coef: 0.6502 - dice_coef: 0.7856 - val_loss: 0.2653 - val_iou_coef: 0.5910 - val_dice_coef: 0.7347
    Epoch 17/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.2097 - iou_coef: 0.6576 - dice_coef: 0.7903 - val_loss: 0.2737 - val_iou_coef: 0.5795 - val_dice_coef: 0.7263
    Epoch 18/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.2084 - iou_coef: 0.6592 - dice_coef: 0.7916 - val_loss: 0.3772 - val_iou_coef: 0.4578 - val_dice_coef: 0.6228
    Epoch 19/40
    8/8 [==============================] - 3s 451ms/step - loss: 0.2334 - iou_coef: 0.6301 - dice_coef: 0.7666 - val_loss: 0.3686 - val_iou_coef: 0.4774 - val_dice_coef: 0.6314
    Epoch 20/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.2022 - iou_coef: 0.6672 - dice_coef: 0.7978 - val_loss: 0.3184 - val_iou_coef: 0.5284 - val_dice_coef: 0.6816
    Epoch 21/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.1989 - iou_coef: 0.6725 - dice_coef: 0.8011 - val_loss: 0.2678 - val_iou_coef: 0.5886 - val_dice_coef: 0.7322
    Epoch 22/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.1913 - iou_coef: 0.6821 - dice_coef: 0.8087 - val_loss: 0.2555 - val_iou_coef: 0.6026 - val_dice_coef: 0.7445
    Epoch 23/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.1971 - iou_coef: 0.6741 - dice_coef: 0.8029 - val_loss: 0.3022 - val_iou_coef: 0.5486 - val_dice_coef: 0.6978
    Epoch 24/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.1881 - iou_coef: 0.6865 - dice_coef: 0.8119 - val_loss: 0.2788 - val_iou_coef: 0.5753 - val_dice_coef: 0.7212
    Epoch 25/40
    8/8 [==============================] - 3s 451ms/step - loss: 0.1893 - iou_coef: 0.6848 - dice_coef: 0.8107 - val_loss: 0.2560 - val_iou_coef: 0.6018 - val_dice_coef: 0.7440
    Epoch 26/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.1957 - iou_coef: 0.6763 - dice_coef: 0.8043 - val_loss: 0.3181 - val_iou_coef: 0.5245 - val_dice_coef: 0.6819
    Epoch 27/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.1950 - iou_coef: 0.6773 - dice_coef: 0.8050 - val_loss: 0.2959 - val_iou_coef: 0.5522 - val_dice_coef: 0.7041
    Epoch 28/40
    8/8 [==============================] - 3s 451ms/step - loss: 0.2058 - iou_coef: 0.6633 - dice_coef: 0.7942 - val_loss: 0.2789 - val_iou_coef: 0.5729 - val_dice_coef: 0.7211
    Epoch 29/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.2087 - iou_coef: 0.6587 - dice_coef: 0.7913 - val_loss: 0.2819 - val_iou_coef: 0.5710 - val_dice_coef: 0.7181
    Epoch 30/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.1904 - iou_coef: 0.6836 - dice_coef: 0.8096 - val_loss: 0.2552 - val_iou_coef: 0.6031 - val_dice_coef: 0.7448
    Epoch 31/40
    8/8 [==============================] - 3s 451ms/step - loss: 0.1701 - iou_coef: 0.7118 - dice_coef: 0.8299 - val_loss: 0.2590 - val_iou_coef: 0.5988 - val_dice_coef: 0.7410
    Epoch 32/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.1741 - iou_coef: 0.7060 - dice_coef: 0.8259 - val_loss: 0.2581 - val_iou_coef: 0.6005 - val_dice_coef: 0.7419
    Epoch 33/40
    8/8 [==============================] - 3s 449ms/step - loss: 0.1714 - iou_coef: 0.7099 - dice_coef: 0.8286 - val_loss: 0.2636 - val_iou_coef: 0.5931 - val_dice_coef: 0.7364
    Epoch 34/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.1728 - iou_coef: 0.7081 - dice_coef: 0.8272 - val_loss: 0.2693 - val_iou_coef: 0.5884 - val_dice_coef: 0.7307
    Epoch 35/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.1783 - iou_coef: 0.7007 - dice_coef: 0.8217 - val_loss: 0.2731 - val_iou_coef: 0.5799 - val_dice_coef: 0.7269
    Epoch 36/40
    8/8 [==============================] - 3s 449ms/step - loss: 0.1826 - iou_coef: 0.6950 - dice_coef: 0.8174 - val_loss: 0.2582 - val_iou_coef: 0.5978 - val_dice_coef: 0.7418
    Epoch 37/40
    8/8 [==============================] - 3s 453ms/step - loss: 0.1746 - iou_coef: 0.7070 - dice_coef: 0.8254 - val_loss: 0.2578 - val_iou_coef: 0.5993 - val_dice_coef: 0.7422
    Epoch 38/40
    8/8 [==============================] - 3s 451ms/step - loss: 0.1738 - iou_coef: 0.7070 - dice_coef: 0.8262 - val_loss: 0.2725 - val_iou_coef: 0.5839 - val_dice_coef: 0.7275
    Epoch 39/40
    8/8 [==============================] - 3s 452ms/step - loss: 0.1842 - iou_coef: 0.6938 - dice_coef: 0.8158 - val_loss: 0.3095 - val_iou_coef: 0.5379 - val_dice_coef: 0.6905
    Epoch 40/40
    8/8 [==============================] - 3s 450ms/step - loss: 0.1806 - iou_coef: 0.6986 - dice_coef: 0.8194 - val_loss: 0.2693 - val_iou_coef: 0.5846 - val_dice_coef: 0.7307
    Epoch 1/60
    4/4 [==============================] - 8s 1s/step - loss: 0.6086 - iou_coef: 0.2553 - dice_coef: 0.3914 - val_loss: 0.5977 - val_iou_coef: 0.2677 - val_dice_coef: 0.4023
    Epoch 2/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.5153 - iou_coef: 0.3349 - dice_coef: 0.4847 - val_loss: 0.5999 - val_iou_coef: 0.2664 - val_dice_coef: 0.4001
    Epoch 3/60
    4/4 [==============================] - 2s 684ms/step - loss: 0.4647 - iou_coef: 0.3801 - dice_coef: 0.5353 - val_loss: 0.6000 - val_iou_coef: 0.2663 - val_dice_coef: 0.4000
    Epoch 4/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.4302 - iou_coef: 0.4124 - dice_coef: 0.5698 - val_loss: 0.6000 - val_iou_coef: 0.2663 - val_dice_coef: 0.4000
    Epoch 5/60
    4/4 [==============================] - 2s 683ms/step - loss: 0.4153 - iou_coef: 0.4262 - dice_coef: 0.5847 - val_loss: 0.5998 - val_iou_coef: 0.2665 - val_dice_coef: 0.4002
    Epoch 6/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.3863 - iou_coef: 0.4548 - dice_coef: 0.6137 - val_loss: 0.5999 - val_iou_coef: 0.2664 - val_dice_coef: 0.4001
    Epoch 7/60
    4/4 [==============================] - 2s 695ms/step - loss: 0.3757 - iou_coef: 0.4658 - dice_coef: 0.6243 - val_loss: 0.5988 - val_iou_coef: 0.2672 - val_dice_coef: 0.4012
    Epoch 8/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.3698 - iou_coef: 0.4718 - dice_coef: 0.6302 - val_loss: 0.5990 - val_iou_coef: 0.2671 - val_dice_coef: 0.4010
    Epoch 9/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.3573 - iou_coef: 0.4850 - dice_coef: 0.6427 - val_loss: 0.5972 - val_iou_coef: 0.2685 - val_dice_coef: 0.4028
    Epoch 10/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.3329 - iou_coef: 0.5101 - dice_coef: 0.6671 - val_loss: 0.5853 - val_iou_coef: 0.2771 - val_dice_coef: 0.4147
    Epoch 11/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.3119 - iou_coef: 0.5337 - dice_coef: 0.6881 - val_loss: 0.5729 - val_iou_coef: 0.2870 - val_dice_coef: 0.4271
    Epoch 12/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.3111 - iou_coef: 0.5351 - dice_coef: 0.6889 - val_loss: 0.5738 - val_iou_coef: 0.2863 - val_dice_coef: 0.4262
    Epoch 13/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.3127 - iou_coef: 0.5324 - dice_coef: 0.6873 - val_loss: 0.5657 - val_iou_coef: 0.2926 - val_dice_coef: 0.4343
    Epoch 14/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.3066 - iou_coef: 0.5402 - dice_coef: 0.6934 - val_loss: 0.5716 - val_iou_coef: 0.2874 - val_dice_coef: 0.4284
    Epoch 15/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.2947 - iou_coef: 0.5534 - dice_coef: 0.7053 - val_loss: 0.5244 - val_iou_coef: 0.3284 - val_dice_coef: 0.4756
    Epoch 16/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2916 - iou_coef: 0.5574 - dice_coef: 0.7084 - val_loss: 0.5604 - val_iou_coef: 0.2968 - val_dice_coef: 0.4396
    Epoch 17/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.3013 - iou_coef: 0.5445 - dice_coef: 0.6987 - val_loss: 0.5547 - val_iou_coef: 0.2992 - val_dice_coef: 0.4453
    Epoch 18/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.3020 - iou_coef: 0.5475 - dice_coef: 0.6980 - val_loss: 0.5918 - val_iou_coef: 0.2727 - val_dice_coef: 0.4082
    Epoch 19/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.2930 - iou_coef: 0.5559 - dice_coef: 0.7070 - val_loss: 0.5274 - val_iou_coef: 0.3244 - val_dice_coef: 0.4726
    Epoch 20/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.2883 - iou_coef: 0.5603 - dice_coef: 0.7117 - val_loss: 0.5844 - val_iou_coef: 0.2776 - val_dice_coef: 0.4156
    Epoch 21/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.2822 - iou_coef: 0.5701 - dice_coef: 0.7178 - val_loss: 0.5854 - val_iou_coef: 0.2769 - val_dice_coef: 0.4146
    Epoch 22/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2699 - iou_coef: 0.5830 - dice_coef: 0.7301 - val_loss: 0.5291 - val_iou_coef: 0.3207 - val_dice_coef: 0.4709
    Epoch 23/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.2605 - iou_coef: 0.5949 - dice_coef: 0.7395 - val_loss: 0.5269 - val_iou_coef: 0.3237 - val_dice_coef: 0.4731
    Epoch 24/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.3005 - iou_coef: 0.5450 - dice_coef: 0.6995 - val_loss: 0.5275 - val_iou_coef: 0.3218 - val_dice_coef: 0.4725
    Epoch 25/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2629 - iou_coef: 0.5925 - dice_coef: 0.7371 - val_loss: 0.5611 - val_iou_coef: 0.2965 - val_dice_coef: 0.4389
    Epoch 26/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.2603 - iou_coef: 0.5947 - dice_coef: 0.7397 - val_loss: 0.4210 - val_iou_coef: 0.4236 - val_dice_coef: 0.5790
    Epoch 27/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.2612 - iou_coef: 0.5935 - dice_coef: 0.7388 - val_loss: 0.5566 - val_iou_coef: 0.2990 - val_dice_coef: 0.4434
    Epoch 28/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2570 - iou_coef: 0.5988 - dice_coef: 0.7430 - val_loss: 0.4526 - val_iou_coef: 0.3946 - val_dice_coef: 0.5474
    Epoch 29/60
    4/4 [==============================] - 2s 687ms/step - loss: 0.2583 - iou_coef: 0.5991 - dice_coef: 0.7417 - val_loss: 0.4503 - val_iou_coef: 0.3891 - val_dice_coef: 0.5497
    Epoch 30/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2546 - iou_coef: 0.6027 - dice_coef: 0.7454 - val_loss: 0.4898 - val_iou_coef: 0.3595 - val_dice_coef: 0.5102
    Epoch 31/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.2546 - iou_coef: 0.6031 - dice_coef: 0.7454 - val_loss: 0.4289 - val_iou_coef: 0.4102 - val_dice_coef: 0.5711
    Epoch 32/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.2836 - iou_coef: 0.5656 - dice_coef: 0.7164 - val_loss: 0.5106 - val_iou_coef: 0.3381 - val_dice_coef: 0.4894
    Epoch 33/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2468 - iou_coef: 0.6114 - dice_coef: 0.7532 - val_loss: 0.4386 - val_iou_coef: 0.4044 - val_dice_coef: 0.5614
    Epoch 34/60
    4/4 [==============================] - 2s 691ms/step - loss: 0.2469 - iou_coef: 0.6115 - dice_coef: 0.7531 - val_loss: 0.5358 - val_iou_coef: 0.3170 - val_dice_coef: 0.4642
    Epoch 35/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2369 - iou_coef: 0.6240 - dice_coef: 0.7631 - val_loss: 0.4641 - val_iou_coef: 0.3782 - val_dice_coef: 0.5359
    Epoch 36/60
    4/4 [==============================] - 2s 692ms/step - loss: 0.2444 - iou_coef: 0.6143 - dice_coef: 0.7556 - val_loss: 0.5135 - val_iou_coef: 0.3345 - val_dice_coef: 0.4865
    Epoch 37/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.2504 - iou_coef: 0.6070 - dice_coef: 0.7496 - val_loss: 0.4917 - val_iou_coef: 0.3568 - val_dice_coef: 0.5083
    Epoch 38/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.2359 - iou_coef: 0.6259 - dice_coef: 0.7641 - val_loss: 0.4710 - val_iou_coef: 0.3748 - val_dice_coef: 0.5290
    Epoch 39/60
    4/4 [==============================] - 2s 691ms/step - loss: 0.2365 - iou_coef: 0.6240 - dice_coef: 0.7635 - val_loss: 0.4456 - val_iou_coef: 0.3944 - val_dice_coef: 0.5544
    Epoch 40/60
    4/4 [==============================] - 2s 691ms/step - loss: 0.2558 - iou_coef: 0.6004 - dice_coef: 0.7442 - val_loss: 0.4221 - val_iou_coef: 0.4194 - val_dice_coef: 0.5779
    Epoch 41/60
    4/4 [==============================] - 2s 686ms/step - loss: 0.1810 - iou_coef: 0.6968 - dice_coef: 0.8190 - val_loss: 0.4206 - val_iou_coef: 0.4204 - val_dice_coef: 0.5794
    Epoch 42/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.1690 - iou_coef: 0.7143 - dice_coef: 0.8310 - val_loss: 0.4201 - val_iou_coef: 0.4265 - val_dice_coef: 0.5799
    Epoch 43/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.1634 - iou_coef: 0.7238 - dice_coef: 0.8366 - val_loss: 0.4228 - val_iou_coef: 0.4150 - val_dice_coef: 0.5772
    Epoch 44/60
    4/4 [==============================] - 2s 687ms/step - loss: 0.1916 - iou_coef: 0.6829 - dice_coef: 0.8084 - val_loss: 0.3675 - val_iou_coef: 0.4751 - val_dice_coef: 0.6325
    Epoch 45/60
    4/4 [==============================] - 2s 691ms/step - loss: 0.1490 - iou_coef: 0.7432 - dice_coef: 0.8510 - val_loss: 0.3221 - val_iou_coef: 0.5249 - val_dice_coef: 0.6779
    Epoch 46/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.1665 - iou_coef: 0.7186 - dice_coef: 0.8335 - val_loss: 0.3709 - val_iou_coef: 0.4700 - val_dice_coef: 0.6291
    Epoch 47/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.1404 - iou_coef: 0.7568 - dice_coef: 0.8596 - val_loss: 0.3258 - val_iou_coef: 0.5186 - val_dice_coef: 0.6742
    Epoch 48/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.1454 - iou_coef: 0.7485 - dice_coef: 0.8546 - val_loss: 0.3143 - val_iou_coef: 0.5343 - val_dice_coef: 0.6857
    Epoch 49/60
    4/4 [==============================] - 2s 683ms/step - loss: 0.1392 - iou_coef: 0.7585 - dice_coef: 0.8608 - val_loss: 0.2910 - val_iou_coef: 0.5609 - val_dice_coef: 0.7090
    Epoch 50/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.1358 - iou_coef: 0.7636 - dice_coef: 0.8642 - val_loss: 0.3669 - val_iou_coef: 0.4749 - val_dice_coef: 0.6331
    Epoch 51/60
    4/4 [==============================] - 2s 681ms/step - loss: 0.1361 - iou_coef: 0.7631 - dice_coef: 0.8639 - val_loss: 0.2905 - val_iou_coef: 0.5602 - val_dice_coef: 0.7095
    Epoch 52/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.1406 - iou_coef: 0.7560 - dice_coef: 0.8594 - val_loss: 0.2949 - val_iou_coef: 0.5558 - val_dice_coef: 0.7051
    Epoch 53/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.1398 - iou_coef: 0.7569 - dice_coef: 0.8602 - val_loss: 0.3106 - val_iou_coef: 0.5358 - val_dice_coef: 0.6894
    Epoch 54/60
    4/4 [==============================] - 2s 685ms/step - loss: 0.1591 - iou_coef: 0.7310 - dice_coef: 0.8409 - val_loss: 0.3202 - val_iou_coef: 0.5293 - val_dice_coef: 0.6798
    Epoch 55/60
    4/4 [==============================] - 2s 691ms/step - loss: 0.1364 - iou_coef: 0.7626 - dice_coef: 0.8636 - val_loss: 0.3119 - val_iou_coef: 0.5337 - val_dice_coef: 0.6881
    Epoch 56/60
    4/4 [==============================] - 2s 687ms/step - loss: 0.1419 - iou_coef: 0.7548 - dice_coef: 0.8581 - val_loss: 0.2812 - val_iou_coef: 0.5721 - val_dice_coef: 0.7188
    Epoch 57/60
    4/4 [==============================] - 2s 688ms/step - loss: 0.1483 - iou_coef: 0.7446 - dice_coef: 0.8517 - val_loss: 0.3076 - val_iou_coef: 0.5383 - val_dice_coef: 0.6924
    Epoch 58/60
    4/4 [==============================] - 2s 689ms/step - loss: 0.1331 - iou_coef: 0.7669 - dice_coef: 0.8669 - val_loss: 0.3180 - val_iou_coef: 0.5259 - val_dice_coef: 0.6820
    Epoch 59/60
    4/4 [==============================] - 2s 690ms/step - loss: 0.1396 - iou_coef: 0.7574 - dice_coef: 0.8604 - val_loss: 0.2819 - val_iou_coef: 0.5709 - val_dice_coef: 0.7181
    Epoch 60/60
    4/4 [==============================] - 2s 685ms/step - loss: 0.1361 - iou_coef: 0.7619 - dice_coef: 0.8639 - val_loss: 0.3526 - val_iou_coef: 0.4854 - val_dice_coef: 0.6474
    Epoch 1/120
    2/2 [==============================] - 7s 3s/step - loss: 0.6735 - iou_coef: 0.2018 - dice_coef: 0.3265 - val_loss: 0.6399 - val_iou_coef: 0.2292 - val_dice_coef: 0.3601
    Epoch 2/120
    2/2 [==============================] - 2s 2s/step - loss: 0.6326 - iou_coef: 0.2332 - dice_coef: 0.3674 - val_loss: 0.6373 - val_iou_coef: 0.2321 - val_dice_coef: 0.3627
    Epoch 3/120
    2/2 [==============================] - 2s 2s/step - loss: 0.5972 - iou_coef: 0.2610 - dice_coef: 0.4028 - val_loss: 0.6295 - val_iou_coef: 0.2393 - val_dice_coef: 0.3705
    Epoch 4/120
    2/2 [==============================] - 2s 2s/step - loss: 0.5681 - iou_coef: 0.2827 - dice_coef: 0.4319 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 5/120
    2/2 [==============================] - 2s 2s/step - loss: 0.5355 - iou_coef: 0.3115 - dice_coef: 0.4645 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 6/120
    2/2 [==============================] - 2s 2s/step - loss: 0.5221 - iou_coef: 0.3234 - dice_coef: 0.4779 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 7/120
    2/2 [==============================] - 2s 2s/step - loss: 0.5114 - iou_coef: 0.3330 - dice_coef: 0.4886 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 8/120
    2/2 [==============================] - 2s 2s/step - loss: 0.5028 - iou_coef: 0.3411 - dice_coef: 0.4972 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 9/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4949 - iou_coef: 0.3484 - dice_coef: 0.5051 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 10/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4872 - iou_coef: 0.3553 - dice_coef: 0.5128 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 11/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4757 - iou_coef: 0.3655 - dice_coef: 0.5243 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 12/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4692 - iou_coef: 0.3710 - dice_coef: 0.5308 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 13/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4585 - iou_coef: 0.3804 - dice_coef: 0.5415 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 14/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4495 - iou_coef: 0.3891 - dice_coef: 0.5505 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 15/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4446 - iou_coef: 0.3939 - dice_coef: 0.5554 - val_loss: 0.6297 - val_iou_coef: 0.2392 - val_dice_coef: 0.3703
    Epoch 16/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4271 - iou_coef: 0.4105 - dice_coef: 0.5729 - val_loss: 0.6296 - val_iou_coef: 0.2393 - val_dice_coef: 0.3704
    Epoch 17/120
    2/2 [==============================] - 2s 2s/step - loss: 0.4104 - iou_coef: 0.4257 - dice_coef: 0.5896 - val_loss: 0.6291 - val_iou_coef: 0.2396 - val_dice_coef: 0.3709
    Epoch 18/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3967 - iou_coef: 0.4391 - dice_coef: 0.6033 - val_loss: 0.6293 - val_iou_coef: 0.2395 - val_dice_coef: 0.3707
    Epoch 19/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3915 - iou_coef: 0.4445 - dice_coef: 0.6085 - val_loss: 0.6276 - val_iou_coef: 0.2407 - val_dice_coef: 0.3724
    Epoch 20/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3879 - iou_coef: 0.4481 - dice_coef: 0.6121 - val_loss: 0.6268 - val_iou_coef: 0.2413 - val_dice_coef: 0.3732
    Epoch 21/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3847 - iou_coef: 0.4510 - dice_coef: 0.6153 - val_loss: 0.6225 - val_iou_coef: 0.2444 - val_dice_coef: 0.3775
    Epoch 22/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3768 - iou_coef: 0.4590 - dice_coef: 0.6232 - val_loss: 0.6255 - val_iou_coef: 0.2422 - val_dice_coef: 0.3745
    Epoch 23/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3715 - iou_coef: 0.4650 - dice_coef: 0.6285 - val_loss: 0.6181 - val_iou_coef: 0.2479 - val_dice_coef: 0.3819
    Epoch 24/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3878 - iou_coef: 0.4467 - dice_coef: 0.6122 - val_loss: 0.6233 - val_iou_coef: 0.2437 - val_dice_coef: 0.3767
    Epoch 25/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3676 - iou_coef: 0.4686 - dice_coef: 0.6324 - val_loss: 0.6095 - val_iou_coef: 0.2549 - val_dice_coef: 0.3905
    Epoch 26/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3692 - iou_coef: 0.4671 - dice_coef: 0.6308 - val_loss: 0.6262 - val_iou_coef: 0.2418 - val_dice_coef: 0.3738
    Epoch 27/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3646 - iou_coef: 0.4717 - dice_coef: 0.6354 - val_loss: 0.6097 - val_iou_coef: 0.2542 - val_dice_coef: 0.3903
    Epoch 28/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3626 - iou_coef: 0.4733 - dice_coef: 0.6374 - val_loss: 0.6168 - val_iou_coef: 0.2485 - val_dice_coef: 0.3832
    Epoch 29/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3754 - iou_coef: 0.4605 - dice_coef: 0.6246 - val_loss: 0.6160 - val_iou_coef: 0.2492 - val_dice_coef: 0.3840
    Epoch 30/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3814 - iou_coef: 0.4538 - dice_coef: 0.6186 - val_loss: 0.5950 - val_iou_coef: 0.2640 - val_dice_coef: 0.4050
    Epoch 31/120
    2/2 [==============================] - 2s 2s/step - loss: 0.3556 - iou_coef: 0.4811 - dice_coef: 0.6444 - val_loss: 0.5772 - val_iou_coef: 0.2787 - val_dice_coef: 0.4228
    Epoch 32/120
    2/2 [==============================] - ETA: 0s - loss: 0.3558 - iou_coef: 0.4814 - dice_coef: 0.6442

notebooks/training of segmentation models.ipynb