      """
  
      # Define vertical and horizontal Scharr filters.
      static_image_shape = image.get_shape()
      image_shape = tf.shape(image)
  
      # modified 3x3 Scharr
      # kernels = [[[-17.0, -61.0, -17.0], [0.0, 0.0, 0.0], [17.0, 61.0, 17.0]],
      #         [[-17.0, 0.0, 17.0], [-61.0, 0.0, 61.0], [-17.0, 0.0, 17.0]]]
  
      # 5x5 Scharr
      kernels = [[[-1.0, -2.0, -3.0, -2.0, -1.0],
                  [-1.0, -2.0, -6.0, -2.0, -1.0],
                  [0.0, 0.0, 0.0, 0.0, 0.0],
                  [1.0, 2.0, 6.0, 2.0, 1.0],
                  [1.0, 2.0, 3.0, 2.0, 1.0]],
                 [[-1.0, -1.0, 0.0, 1.0, 1.0],
                  [-2.0, -2.0, 0.0, 2.0, 2.0],
                  [-3.0, -6.0, 0.0, 6.0, 3.0],
                  [-2.0, -2.0, 0.0, 2.0, 2.0],
                  [-1.0, -1.0, 0.0, 1.0, 1.0]]]
      num_kernels = len(kernels)
      kernels = np.transpose(np.asarray(kernels), (1, 2, 0))
      kernels = np.expand_dims(kernels, -2) / np.sum(np.abs(kernels))
      kernels_tf = tf.constant(kernels, dtype=image.dtype)
      kernels_tf = tf.tile(kernels_tf, [1, 1, image_shape[-1], 1], name='scharr_filters')
  
      # Use depth-wise convolution to calculate edge maps per channel.
      pad_sizes = [[0, 0], [2, 2], [2, 2], [0, 0]]
      padded = tf.pad(image, pad_sizes, mode='REFLECT')
  
 
</s> remove     # Output tensor has shape [batch_size, h, w, d * num_kernels].
    strides = [1, 1, 1, 1]
    output = tf.nn.depthwise_conv2d(padded, kernels_tf, strides, 'VALID')

    # Reshape to [batch_size, h, w, d, num_kernels].
    shape = tf.concat([image_shape, [num_kernels]], 0)
    output = tf.reshape(output, shape=shape)
    output.set_shape(static_image_shape.concatenate([num_kernels]))

    if magnitude:  # magnitude of edges
        output = tf.sqrt(tf.reduce_sum(tf.square(output), axis=-1))
    else:  # direction of edges
        output = tf.atan(tf.squeeze(tf.div(output[:, :, :, :, 0]/output[:, :, :, :, 1])))
 </s> add     if not magnitude:  # direction of edges
        # Reshape to [batch_size, h, w, d, num_kernels].
        shape = K.concatenate([image_shape, num_kernels], axis=0)
        output = K.reshape(output, shape=shape)
        output.set_shape(static_image_shape.concatenate(num_kernels))
        output = tf.atan(K.squeeze(output[:, :, :, :, 0] / output[:, :, :, :, 1]))
    # magnitude of edges -- unified x & y edges don't work well with NN </s> remove def staircase_loss(y_true, y_pred, var_a=16.0, cnst=1.0/255.0):
    """ Keras Staircase Loss """
    height = cnst
    width = cnst
    var_x = K.clip(K.abs(y_true - y_pred) - 0.5 * cnst, 0.0, 1.0)
    loss = height*(K.tanh(var_a*((var_x/width)-tf.floor(var_x/width)-0.5)) /
                   (2.0*K.tanh(var_a/2.0)) + 0.5 + tf.floor(var_x/width))
    loss += 1e-10
    return K.mean(loss, axis=-1)
 </s> add def l_p_norm(y_true, y_pred, p_norm=np.inf):
    """
    Calculate the L-p norm as a loss function,
    valid choics of p are [0,1,no.inf]
    """
    diff = y_true - y_pred
    loss = tf.norm(diff, ord=p_norm, axis=-1)
    return loss


def l_inf_norm(y_true, y_pred):
    """ Calculate the L-inf norm as a loss function """
    diff = K.abs(y_true - y_pred)
    max_loss = K.max(diff, axis=(1, 2), keepdims=True)
    loss = K.mean(max_loss, axis=-1)
    return loss </s> remove     true_edge_mag = scharr_edges(y_true, True)
    pred_edge_mag = scharr_edges(y_pred, True)
    cnst = 0.002
    upper = 2.0 * tf.multiply(true_edge_mag, pred_edge_mag) + cnst
    lower = tf.square(true_edge_mag) + tf.square(pred_edge_mag) + cnst
    gms = tf.div(upper, lower)
    _mean, _var = tf.nn.moments(gms, axes=[1, 2], keep_dims=True)
    # single metric value per image in tensor [?, 1, 1]
    gmsd = tf.reduce_mean(tf.sqrt(_var), axis=-1)
    # need to expand to [?, height, width] dimensions for Keras ... modify to not be hard-coded
    return K.tile(gmsd, [1, 64, 64])


def ms_ssim(img1, img2, max_val=1.0, power_factors=(0.0517, 0.3295, 0.3462, 0.2726)):
 </s> add     true_edge = scharr_edges(y_true, True)
    pred_edge = scharr_edges(y_pred, True)
    ephsilon = 0.0025
    upper = 2.0 * true_edge * pred_edge
    lower = K.square(true_edge) + K.square(pred_edge)
    gms = (upper + ephsilon) / (lower + ephsilon)
    gmsd = K.std(gms, axis=(1, 2, 3), keepdims=True)
    gmsd = K.squeeze(gmsd, axis=-1)
    return gmsd


def ms_ssim_calc(img1, img2, max_val=1.0, power_factors=(0.0517, 0.3295, 0.3462, 0.2726)):
    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

      """
  
      # Define vertical and horizontal Scharr filters.
      static_image_shape = image.get_shape()
    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

    image_shape = K.shape(image)

    # 5x5 modified Scharr kernel ( reshape to (5,5,1,2) )
    matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
    num_kernels = [2]
    kernels = K.constant(matrix, dtype='float32')
    kernels = K.tile(kernels, [1, 1, image_shape[-1], 1])

  
      # Use depth-wise convolution to calculate edge maps per channel.
      pad_sizes = [[0, 0], [2, 2], [2, 2], [0, 0]]
      padded = tf.pad(image, pad_sizes, mode='REFLECT')
  
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 documentation, pep8, style, clarity updates  - Prep for Segmentation (#812)

* documentation, pep8, style, clarity updates

* Update cli.py

* Update _config.py

remove extra mask and coverage

mask type as dropdown

* Update training_data.py

move coverage / LR to global
cut down on loss description

style change
losses working in PR

* simpler logging

* legacy update 
lib/model/losses.py