예제 #1
0
                                        axis=3),
                              output_channel=4,
                              ext='Trans_')
    # lossDict["percep_t"] = 0.1 * compute_percep_loss(img_no_shadow, no_shadow_layer, reuse=False)
    lossDict["percep_t"] = 0.1 * tf.reduce_mean(
        tf.abs(img_no_shadow - no_shadow_layer))
    # lossDict["percep_r"] = 0.1 * compute_percep_loss(shadow_mask, shadow_mask_layer, reuse=True)
    lossDict["percep_r"] = 0.1 * tf.reduce_mean(
        tf.abs(shadow_mask - shadow_mask_layer))
    lossDict["total"] = lossDict["percep_t"] + lossDict["percep_r"]
    tf_psnr = tf.math.reduce_mean(
        tf.image.psnr(tf.clip_by_value(img_no_shadow, 0, 1),
                      tf.clip_by_value(no_shadow_layer, 0, 1), 1.0))
    encoded_concat = encode_jpeg(
        concat_img(
            (linref2srgb(img_with_shadow[0]), linref2srgb(no_shadow_layer[0]),
             linref2srgb(img_no_shadow[0]), linref2srgb(input_pureflash[0]),
             rgbg2rgb(shadow_mask_layer[0]), rgbg2rgb(shadow_mask[0]))))

train_vars = tf.trainable_variables()

R_vars = [var for var in train_vars if 'Ref_' in var.name]
T_vars = [var for var in train_vars if 'Trans_' in var.name]
all_vars = [var for var in train_vars if 'g_' in var.name]

for var in R_vars:
    print(var)
for var in T_vars:
    print(var)
opt = tf.train.AdamOptimizer(learning_rate=0.0001).minimize(lossDict["total"],
                                                            var_list=all_vars)
                ext='Ref_'))
    no_shadow_layer = UNet_SE(tf.concat([img_with_shadow, shadow_mask_layer],
                                        axis=3),
                              ext='Trans_')
    lossDict["percep_t"] = 0.1 * compute_percep_loss(
        img_no_shadow, no_shadow_layer, reuse=False)
    lossDict["percep_r"] = 0.1 * tf.reduce_mean(
        tf.square(shadow_mask - shadow_mask_layer))
    # lossDict["percep_r"] = 0.1 * compute_percep_loss(shadow_mask, shadow_mask_layer, reuse=True)
    lossDict["total"] = lossDict["percep_t"] + lossDict["percep_r"]
    tf_psnr = tf.math.reduce_mean(
        tf.image.psnr(tf.clip_by_value(img_no_shadow, 0, 1),
                      tf.clip_by_value(no_shadow_layer, 0, 1), 1.0))
    encoded_concat = encode_jpeg(
        concat_img((img_with_shadow[0], no_shadow_layer[0], img_no_shadow[0],
                    input_pureflash[0],
                    tf.image.grayscale_to_rgb(shadow_mask_layer[0]),
                    tf.image.grayscale_to_rgb(shadow_mask[0]))))

train_vars = tf.trainable_variables()

R_vars = [var for var in train_vars if 'Ref_' in var.name]
T_vars = [var for var in train_vars if 'Trans_' in var.name]
all_vars = [var for var in train_vars if 'g_' in var.name]

for var in R_vars:
    print(var)
for var in T_vars:
    print(var)
opt = tf.train.AdamOptimizer(learning_rate=0.0001).minimize(lossDict["total"],
                                                            var_list=all_vars)
예제 #3
0
    # shadow_mask_layer = UNet_SE(tf.concat([img_with_shadow, gray_pureflash], axis=3), output_channel = 3, ext='Ref_')
    # tf.math.sigmoid()
    no_shadow_layer = UNet_SE(tf.concat([img_with_shadow, shadow_mask_layer],
                                        axis=3),
                              ext='Trans_')
    lossDict["percep_t"] = 0.1 * compute_percep_loss(
        img_no_shadow, no_shadow_layer, reuse=False)
    # lossDict["percep_r"]=0.1* tf.reduce_mean(tf.abs(shadow_mask-shadow_mask_layer))
    lossDict["percep_r"] = 0.1 * compute_percep_loss(
        shadow_mask, shadow_mask_layer, reuse=True)
    lossDict["total"] = lossDict["percep_t"] + lossDict["percep_r"]
    tf_psnr = tf.math.reduce_mean(
        tf.image.psnr(tf.clip_by_value(img_no_shadow, 0, 1),
                      tf.clip_by_value(no_shadow_layer, 0, 1), 1.0))
    encoded_concat = encode_jpeg(
        concat_img((img_with_shadow[0], no_shadow_layer[0], img_no_shadow[0],
                    input_pureflash[0], shadow_mask_layer[0], shadow_mask[0])))

train_vars = tf.trainable_variables()

R_vars = [var for var in train_vars if 'Ref_' in var.name]
T_vars = [var for var in train_vars if 'Trans_' in var.name]
all_vars = [var for var in train_vars if 'g_' in var.name]

# for var in R_vars: 	print(var)
# for var in T_vars:	print(var)
opt = tf.train.AdamOptimizer(learning_rate=0.0001).minimize(lossDict["total"],
                                                            var_list=all_vars)

# for var in tf.trainable_variables():
#     print("Listing trainable variables ... ")
#     print(var)
        reflection_layer = UNet_SE(tf.concat([img_with_shadow, gray_pureflash], axis=3), output_channel = 4, ext='Ref_')

    tran_layer = UNet_SE(tf.concat([img_with_shadow, reflection_layer], axis=3),output_channel = 4, ext='Trans_')
    # lossDict["percep_t"] = 0.1 * compute_percep_loss(ref_gt, tran_layer, reuse=False)    
    lossDict["percep_t"]=0.1* tf.reduce_mean(tf.abs(tran_gt- tran_layer))
    # lossDict["percep_r"] = 0.1 * compute_percep_loss(tran_gt, reflection_layer, reuse=True) 
    lossDict["percep_r"]=0.1* tf.reduce_mean(tf.abs(ref_gt-reflection_layer))
    lossDict["total"] = lossDict["percep_t"] + lossDict["percep_r"]
    if RGB_PSNR:
        tf_psnr=tf.math.reduce_mean(tf.image.psnr(tf.clip_by_value(linref2srgb(ref_gt[0]),0,1),
                        tf.clip_by_value(linref2srgb(tran_layer[0]),0,1),1.0))
    else:
        tf_psnr=tf.math.reduce_mean(tf.image.psnr(tf.clip_by_value(ref_gt,0,1),
                        tf.clip_by_value(tran_layer,0,1),1.0))
    encoded_concat=encode_jpeg(
        concat_img((linref2srgb(img_with_shadow[0]),linref2srgb(tran_layer[0]),linref2srgb(tran_gt[0]),
            linref2srgb(input_pureflash[0]),linref2srgb(reflection_layer[0]), linref2srgb(ref_gt[0]))))



train_vars = tf.trainable_variables()

R_vars = [var for var in train_vars if 'Ref_' in var.name]
T_vars = [var for var in train_vars if 'Trans_' in var.name]
all_vars=[var for var in train_vars if 'g_' in var.name]
tran_layer
# for var in R_vars: 	print(var)
# for var in T_vars:	print(var)
opt=tf.train.AdamOptimizer(learning_rate=0.0001).minimize(lossDict["total"],var_list=all_vars)


# for var in tf.trainable_variables():