Example segmentation with DeepLabv3+

[1]:
import numpy as np
from glob import glob
import tensorflow as tf

[2]:
from tensorflow import keras
from tensorflow.keras.layers import Input, Conv2D, Dropout, Activation, UpSampling2D, GlobalMaxPooling2D, multiply
from tensorflow.keras.backend import max
[3]:
gpus = tf.config.experimental.list_physical_devices("GPU")
#os.environ['TF_GPU_ALLOCATOR'] = 'cuda_malloc_async'


if gpus:
    try:
        tf.config.experimental.set_virtual_device_configuration(
            gpus[0],
            [
                tf.config.experimental.VirtualDeviceConfiguration(
                    memory_limit=1024 * 24
                )
            ],
        )
    except RuntimeError as e:
        print(e)

This example requires swiss_army_keras or higher:

pip3 install swiss_army_keras
[4]:
#!pip3 install --upgrade git+https://github.com/waterviewsrl/swiss-army-keras.git
from swiss_army_keras import models, base, utils, quantization_utils, training_utils, dataset_utils
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-g1cfk7fj because the default path (/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
[5]:
# the indicator of a fresh run
first_time_running = False

# user-specified working directory
filepath = './oxford_iiit/'

The Oxford-IIIT Pets dataset

This example applies the dataset of Oxford-IIIT Pet Dataset (Parkhi et al. 2012). This dataset contains images of pets and their pixel-wise mask that indicates (1) pixels belonging to the pet, (2) pixels bordering the pet, and (3) surrounding pixels.

The Oxford-IIIT Pets dataset will be downloaded and unpacked through the cell blow.

[6]:
if first_time_running:
    # downloading and executing data files
    import tarfile
    import urllib.request

    filename_image = filepath+'images.tar.gz'
    filename_target = filepath+'annotations.tar.gz'

    urllib.request.urlretrieve('http://www.robots.ox.ac.uk/~vgg/data/pets/data/images.tar.gz', filename_image);
    urllib.request.urlretrieve('https://www.robots.ox.ac.uk/~vgg/data/pets/data/annotations.tar.gz', filename_target);

    with tarfile.open(filename_image, "r:gz") as tar_io:
        tar_io.extractall(path=filepath)
    with tarfile.open(filename_target, "r:gz") as tar_io:
        tar_io.extractall(path=filepath)

    os.system(f'cd {filepath} && cd images && rm *.mat && cd../../')
[7]:
import albumentations as albu

[8]:
from swiss_army_keras.dataset_utils import SegmentationAlbumentationsDataLoader
from weathermentations.rain import DropsOnLens
[9]:
n_labels = 3

input_tensor = tf.keras.layers.Input((256, 256, 3), batch_size=1)

X_decoder = models.deeplab_v3_plus(input_tensor,
                                   n_labels=n_labels,
                                   backbone='EfficientNetLiteB0',
                                   atrous_rates=[],
                                   deep_layer=5,
                                   activation='ReLU',
                                   batch_norm=True,
                                   pool=True,
                                   unpool=True,
                                   name='Pets')



OUT_stack = X_decoder(input_tensor)
deeplabv3plus = keras.models.Model([input_tensor,], OUT_stack)
deeplabv3plus.preprocessing = X_decoder.preprocessing
deeplabv3plus.summary()
KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'")
Model: "model_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input_1 (InputLayer)         [(1, 256, 256, 3)]        0
_________________________________________________________________
model (Functional)           (1, 256, 256, 3)          4652771
=================================================================
Total params: 4,652,771
Trainable params: 2,021,731
Non-trainable params: 2,631,040
_________________________________________________________________
[ ]:

[10]:
def get_training_augmentation(width=513, height=513):
    train_transform = [


        #albu.RandomRotate90(p=0.5),

        #albu.OneOf([
        #
        #
        #], p=1),
        #albu.Resize(width, height, 2, p=1),

        #albu.ShiftScaleRotate(shift_limit = 0.05, scale_limit=(0.1, 0.1), interpolation=2, rotate_limit=25, p=0.3),

        albu.HorizontalFlip(p=0.5),
        #albu.VerticalFlip(p=0.15),

        albu.Compose([
        albu.OneOf([
            albu.ISONoise(p=1),
            albu.MultiplicativeNoise(p=1),
            albu.GaussNoise(p=1),
            albu.ImageCompression(p=1),

            ],
            p=1,
        ),

        #albu.Perspective(pad_mode=2, p=0.1),

        albu.OneOf(
            [
                albu.CLAHE(p=1),
                albu.RandomBrightnessContrast(p=1),
                albu.Sharpen(p=1),
                albu.Emboss(p=1),
                albu.RandomGamma(p=1),
            ],
            p=0.5,
        ),

        albu.OneOf(
            [
                albu.Blur(blur_limit=5, p=1),
                albu.MedianBlur(blur_limit=5, p=1),
                albu.MotionBlur(blur_limit=5, p=1),
            ],
            p=0.25,
        ),

        albu.OneOf(
            [
                albu.RandomBrightnessContrast(p=1),
                albu.HueSaturationValue(p=1),
                albu.RGBShift(p=1),
            ],
            p=0.25,
        ),

        albu.OneOf(
            [
                #albu.ElasticTransform(alpha=10, sigma=10 * 0.05, alpha_affine=10 * 0.03, p=0.5),
                albu.GridDistortion(p=0.5),
                albu.OpticalDistortion(distort_limit=0.3, shift_limit=0.05, p=1)
            ],
            p=0.25,
        )], p=0.5),

        #DropsOnLens(maxR=40, minR=30, p=0.1),
        albu.ToGray(p=0.2)
    ]

    return albu.Compose(train_transform)
    #return albu.Compose([])


loader = SegmentationAlbumentationsDataLoader(num_classes=3,
                                              #precache=True,
                                              batch_size=16,
                                              width=256,
                                              height=256,
                                              dataset_path=filepath,
                                              masks_dir='annotations/trimaps',
                                              train_augmentations=get_training_augmentation(64, 64),
                                              label_shift=1,
                                              train_val_test_split=[0.8, 0.1, 0.1],
                                              normalization=deeplabv3plus.preprocessing,
                                              )

WARNING:root:Normalizing in range: [-1.  1.]
Train Images are good to go
WARNING:root:KEYS: None
WARNING:root:Router on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:KEYS: (b'P+S690P{iVPfx<aFJwxfSY^ugFzjuWOnaIh!o7J<', b':$80ST.hxA5xL7c+@$3YTEohOR^GhrJ2$qzN@bR^')
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Attaching HOST CURVE keys.
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 128, 'value': 93, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CLOSED'}
WARNING:root:KEYS: None
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4, 'value': 297, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECT_RETRIED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 128, 'value': 94, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CLOSED'}
WARNING:root:Router on "ipc:///tmp/swiss_army_keras_segmentation_curve_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4, 'value': 297, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECT_RETRIED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 8, 'value': 104, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_LISTENING'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_curve_socket_HruyKtc=): {'event': 8, 'value': 105, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_curve_socket_HruyKtc=', 'description': 'EVENT_LISTENING'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 95, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 106, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 96, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 107, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 98, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 108, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 98, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 111, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 99, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 109, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 93, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 101, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 122, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 94, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 110, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 101, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 124, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 102, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 112, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 113, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 103, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 127, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 104, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 114, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 115, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 106, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:KEYS: None
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 116, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 106, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 117, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 107, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 111, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 118, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 108, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 119, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 109, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:KEYS: None
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 134, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Dealer on "ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc="
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 32, 'value': 120, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_ACCEPTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 1, 'value': 110, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_CONNECTED'}
WARNING:root:Event Monitor(Host: ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=): {'event': 4096, 'value': 0, 'endpoint': b'ipc:///tmp/swiss_army_keras_segmentation_clear_socket_HruyKtc=', 'description': 'EVENT_HANDSHAKE_SUCCEEDED'}
[11]:
train_set, val_set, test_set = loader.build_datasets()
[12]:
loader.show_images(dset='train', num_images=16)
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_0.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_1.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_2.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_3.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_4.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_5.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_6.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_7.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_8.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_9.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_10.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_11.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_12.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_13.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_14.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_15_15.png
[13]:
from swiss_army_keras import losses, metrics
[14]:
loss = losses.loss_adapter(losses.symmetrical_unified_focal_loss(), from_logits=True, label_smoothing=0.1)
accuracy = tf.keras.metrics.CategoricalAccuracy()
miou = metrics.MeanIOU(num_classes=n_labels)
[15]:
from swiss_army_keras.training_utils import TrainingDriver
from adabelief_tf import AdaBeliefOptimizer
[16]:
td = TrainingDriver(deeplabv3plus,'pets_model', AdaBeliefOptimizer(), loss, [accuracy, miou], train_set, val_set, test_set, 20 )
Please check your arguments if you have upgraded adabelief-tf from version 0.0.1.
Modifications to default arguments:
                           eps  weight_decouple    rectify
-----------------------  -----  -----------------  -------------
adabelief-tf=0.0.1       1e-08  Not supported      Not supported
>=0.1.0 (Current 0.2.1)  1e-14  supported          default: True
SGD better than Adam (e.g. CNN for Image Classification)    Adam better than SGD (e.g. Transformer, GAN)
----------------------------------------------------------  ----------------------------------------------
Recommended epsilon = 1e-7                                  Recommended epsilon = 1e-14
For a complete table of recommended hyperparameters, see
https://github.com/juntang-zhuang/Adabelief-Optimizer
You can disable the log message by setting "print_change_log = False", though it is recommended to keep as a reminder.

[17]:
td.run()
Model: "model_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input_1 (InputLayer)         [(1, 256, 256, 3)]        0
_________________________________________________________________
model (Functional)           (1, 256, 256, 3)          4652771
=================================================================
Total params: 4,652,771
Trainable params: 2,021,731
Non-trainable params: 2,631,040
_________________________________________________________________
Epoch 1/20
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
/usr/local/lib/python3.6/dist-packages/keras/utils/generic_utils.py:497: CustomMaskWarning: Custom mask layers require a config and must override get_config. When loading, the custom mask layer must be passed to the custom_objects argument.
  category=CustomMaskWarning)
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
369/369 [==============================] - ETA: 0s - loss: 0.4020 - categorical_accuracy: 0.8556 - mean_iou: 0.6432WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
369/369 [==============================] - 34s 72ms/step - loss: 0.4020 - categorical_accuracy: 0.8556 - mean_iou: 0.6432 - val_loss: 0.3942 - val_categorical_accuracy: 0.8722 - val_mean_iou: 0.6910
Epoch 2/20
369/369 [==============================] - 25s 68ms/step - loss: 0.3573 - categorical_accuracy: 0.8992 - mean_iou: 0.7252 - val_loss: 0.3513 - val_categorical_accuracy: 0.9059 - val_mean_iou: 0.7555
Epoch 3/20
369/369 [==============================] - 25s 68ms/step - loss: 0.3472 - categorical_accuracy: 0.9085 - mean_iou: 0.7450 - val_loss: 0.3609 - val_categorical_accuracy: 0.8975 - val_mean_iou: 0.7307
Epoch 4/20
369/369 [==============================] - 25s 68ms/step - loss: 0.3427 - categorical_accuracy: 0.9128 - mean_iou: 0.7541 - val_loss: 0.3413 - val_categorical_accuracy: 0.9147 - val_mean_iou: 0.7666
Epoch 5/20
369/369 [==============================] - 25s 68ms/step - loss: 0.3392 - categorical_accuracy: 0.9159 - mean_iou: 0.7611 - val_loss: 0.3381 - val_categorical_accuracy: 0.9161 - val_mean_iou: 0.7653
Epoch 6/20
369/369 [==============================] - 25s 68ms/step - loss: 0.3365 - categorical_accuracy: 0.9185 - mean_iou: 0.7671 - val_loss: 0.3359 - val_categorical_accuracy: 0.9190 - val_mean_iou: 0.7677
Epoch 7/20
369/369 [==============================] - 25s 68ms/step - loss: 0.3338 - categorical_accuracy: 0.9206 - mean_iou: 0.7719 - val_loss: 0.3448 - val_categorical_accuracy: 0.9122 - val_mean_iou: 0.7718
Epoch 8/20
369/369 [==============================] - 25s 68ms/step - loss: 0.3324 - categorical_accuracy: 0.9220 - mean_iou: 0.7749 - val_loss: 0.3363 - val_categorical_accuracy: 0.9185 - val_mean_iou: 0.7703
Epoch 9/20
369/369 [==============================] - 25s 69ms/step - loss: 0.3311 - categorical_accuracy: 0.9231 - mean_iou: 0.7774 - val_loss: 0.3293 - val_categorical_accuracy: 0.9246 - val_mean_iou: 0.7814
Epoch 10/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3290 - categorical_accuracy: 0.9247 - mean_iou: 0.7811 - val_loss: 0.3298 - val_categorical_accuracy: 0.9246 - val_mean_iou: 0.7860
Epoch 11/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3277 - categorical_accuracy: 0.9260 - mean_iou: 0.7841 - val_loss: 0.3350 - val_categorical_accuracy: 0.9196 - val_mean_iou: 0.7772
Epoch 12/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3270 - categorical_accuracy: 0.9264 - mean_iou: 0.7854 - val_loss: 0.3396 - val_categorical_accuracy: 0.9155 - val_mean_iou: 0.7709
Epoch 13/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3249 - categorical_accuracy: 0.9283 - mean_iou: 0.7895 - val_loss: 0.3311 - val_categorical_accuracy: 0.9233 - val_mean_iou: 0.7847
Epoch 14/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3248 - categorical_accuracy: 0.9283 - mean_iou: 0.7897 - val_loss: 0.3342 - val_categorical_accuracy: 0.9208 - val_mean_iou: 0.7768
Epoch 15/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3232 - categorical_accuracy: 0.9296 - mean_iou: 0.7924 - val_loss: 0.3303 - val_categorical_accuracy: 0.9235 - val_mean_iou: 0.7871
Epoch 16/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3226 - categorical_accuracy: 0.9302 - mean_iou: 0.7943 - val_loss: 0.3273 - val_categorical_accuracy: 0.9269 - val_mean_iou: 0.7877
Epoch 17/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3213 - categorical_accuracy: 0.9313 - mean_iou: 0.7963 - val_loss: 0.3287 - val_categorical_accuracy: 0.9251 - val_mean_iou: 0.7878
Epoch 18/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3207 - categorical_accuracy: 0.9319 - mean_iou: 0.7979 - val_loss: 0.3296 - val_categorical_accuracy: 0.9248 - val_mean_iou: 0.7900
Epoch 19/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3192 - categorical_accuracy: 0.9331 - mean_iou: 0.8008 - val_loss: 0.3265 - val_categorical_accuracy: 0.9270 - val_mean_iou: 0.7960
Epoch 20/20
369/369 [==============================] - 26s 70ms/step - loss: 0.3182 - categorical_accuracy: 0.9339 - mean_iou: 0.8023 - val_loss: 0.3279 - val_categorical_accuracy: 0.9259 - val_mean_iou: 0.7865
WARNING:root:Unfreezing Model
Model: "model_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input_1 (InputLayer)         [(1, 256, 256, 3)]        0
_________________________________________________________________
model (Functional)           (1, 256, 256, 3)          4652771
=================================================================
Total params: 4,652,771
Trainable params: 4,611,299
Non-trainable params: 41,472
_________________________________________________________________
Epoch 1/20
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
369/369 [==============================] - ETA: 0s - loss: 0.3725 - categorical_accuracy: 0.8885 - mean_iou: 0.7141WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
WARNING:tensorflow:Model was constructed with shape (1, 256, 256, 3) for input KerasTensor(type_spec=TensorSpec(shape=(1, 256, 256, 3), dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'"), but it was called on an input with incompatible shape (16, 256, 256, 3).
369/369 [==============================] - 79s 158ms/step - loss: 0.3725 - categorical_accuracy: 0.8885 - mean_iou: 0.7141 - val_loss: 0.3536 - val_categorical_accuracy: 0.9022 - val_mean_iou: 0.7398
Epoch 2/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3466 - categorical_accuracy: 0.9086 - mean_iou: 0.7514 - val_loss: 0.3413 - val_categorical_accuracy: 0.9133 - val_mean_iou: 0.7657
Epoch 3/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3382 - categorical_accuracy: 0.9162 - mean_iou: 0.7665 - val_loss: 0.3346 - val_categorical_accuracy: 0.9198 - val_mean_iou: 0.7775
Epoch 4/20
369/369 [==============================] - 55s 148ms/step - loss: 0.3327 - categorical_accuracy: 0.9211 - mean_iou: 0.7763 - val_loss: 0.3299 - val_categorical_accuracy: 0.9233 - val_mean_iou: 0.7848
Epoch 5/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3298 - categorical_accuracy: 0.9237 - mean_iou: 0.7820 - val_loss: 0.3296 - val_categorical_accuracy: 0.9239 - val_mean_iou: 0.7882
Epoch 6/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3274 - categorical_accuracy: 0.9256 - mean_iou: 0.7861 - val_loss: 0.3270 - val_categorical_accuracy: 0.9259 - val_mean_iou: 0.7867
Epoch 7/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3244 - categorical_accuracy: 0.9285 - mean_iou: 0.7923 - val_loss: 0.3286 - val_categorical_accuracy: 0.9250 - val_mean_iou: 0.7894
Epoch 8/20
369/369 [==============================] - 54s 146ms/step - loss: 0.3231 - categorical_accuracy: 0.9295 - mean_iou: 0.7942 - val_loss: 0.3310 - val_categorical_accuracy: 0.9223 - val_mean_iou: 0.7835
Epoch 9/20
369/369 [==============================] - 55s 148ms/step - loss: 0.3209 - categorical_accuracy: 0.9314 - mean_iou: 0.7983 - val_loss: 0.3263 - val_categorical_accuracy: 0.9270 - val_mean_iou: 0.7944
Epoch 10/20
369/369 [==============================] - 54s 145ms/step - loss: 0.3197 - categorical_accuracy: 0.9324 - mean_iou: 0.8006 - val_loss: 0.3268 - val_categorical_accuracy: 0.9261 - val_mean_iou: 0.7907
Epoch 11/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3182 - categorical_accuracy: 0.9337 - mean_iou: 0.8034 - val_loss: 0.3222 - val_categorical_accuracy: 0.9304 - val_mean_iou: 0.7989
Epoch 12/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3183 - categorical_accuracy: 0.9338 - mean_iou: 0.8039 - val_loss: 0.3264 - val_categorical_accuracy: 0.9273 - val_mean_iou: 0.7977
Epoch 13/20
369/369 [==============================] - 54s 148ms/step - loss: 0.3168 - categorical_accuracy: 0.9350 - mean_iou: 0.8064 - val_loss: 0.3264 - val_categorical_accuracy: 0.9276 - val_mean_iou: 0.7952
Epoch 14/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3149 - categorical_accuracy: 0.9365 - mean_iou: 0.8101 - val_loss: 0.3242 - val_categorical_accuracy: 0.9292 - val_mean_iou: 0.7985
Epoch 15/20
369/369 [==============================] - 55s 148ms/step - loss: 0.3142 - categorical_accuracy: 0.9371 - mean_iou: 0.8115 - val_loss: 0.3274 - val_categorical_accuracy: 0.9272 - val_mean_iou: 0.7959
Epoch 16/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3145 - categorical_accuracy: 0.9367 - mean_iou: 0.8109 - val_loss: 0.3215 - val_categorical_accuracy: 0.9309 - val_mean_iou: 0.8016
Epoch 17/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3130 - categorical_accuracy: 0.9380 - mean_iou: 0.8135 - val_loss: 0.3233 - val_categorical_accuracy: 0.9295 - val_mean_iou: 0.7984
Epoch 18/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3117 - categorical_accuracy: 0.9391 - mean_iou: 0.8162 - val_loss: 0.3201 - val_categorical_accuracy: 0.9322 - val_mean_iou: 0.8038
Epoch 19/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3136 - categorical_accuracy: 0.9375 - mean_iou: 0.8128 - val_loss: 0.3252 - val_categorical_accuracy: 0.9280 - val_mean_iou: 0.7962
Epoch 20/20
369/369 [==============================] - 54s 147ms/step - loss: 0.3119 - categorical_accuracy: 0.9389 - mean_iou: 0.8158 - val_loss: 0.3201 - val_categorical_accuracy: 0.9322 - val_mean_iou: 0.8035
WARNING:root:Quantizing Model
WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.
WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.
INFO:tensorflow:Assets written to: /tmp/tmpuq2_6gro/assets
INFO:tensorflow:Assets written to: /tmp/tmpuq2_6gro/assets
/usr/local/lib/python3.6/dist-packages/keras/utils/generic_utils.py:497: CustomMaskWarning: Custom mask layers require a config and must override get_config. When loading, the custom mask layer must be passed to the custom_objects argument.
  category=CustomMaskWarning)
WARNING:absl:For model inputs containing unsupported operations which cannot be quantized, the `inference_input_type` attribute will default to the original type.
WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.
WARNING:tensorflow:Compiled the loaded model, but the compiled metrics have yet to be built. `model.compile_metrics` will be empty until you train or evaluate the model.
INFO:tensorflow:Assets written to: /tmp/tmpobro38yf/assets
INFO:tensorflow:Assets written to: /tmp/tmpobro38yf/assets
/usr/local/lib/python3.6/dist-packages/keras/utils/generic_utils.py:497: CustomMaskWarning: Custom mask layers require a config and must override get_config. When loading, the custom mask layer must be passed to the custom_objects argument.
  category=CustomMaskWarning)
<Figure size 432x288 with 0 Axes>
[18]:
loader.show_results(deeplabv3plus, 16)
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_0.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_1.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_2.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_3.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_4.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_5.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_6.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_7.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_8.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_9.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_10.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_11.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_12.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_13.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_14.png
../_images/notebooks_segmentation_deeplab-v3-plus_oxford-iiit_21_15.png
[ ]: