From e28e8942b06af66944df09294a2d9aaaac49bbf3 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 15 Dec 2019 12:48:48 +0100 Subject: 7abc fixed --- inversion/image_inversion_inception.py | 46 +++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'inversion/image_inversion_inception.py') diff --git a/inversion/image_inversion_inception.py b/inversion/image_inversion_inception.py index 80c1729..5e68bc9 100644 --- a/inversion/image_inversion_inception.py +++ b/inversion/image_inversion_inception.py @@ -220,17 +220,23 @@ if params.features: gen_feat_ex = feature_extractor(dict(images=gen_img_1), as_dict=True, signature='image_feature_vector') target_feat_ex = feature_extractor(dict(images=target_img_1), as_dict=True, signature='image_feature_vector') - # gen_feat = gen_feat_ex["InceptionV3/Mixed_7a"] - # target_feat = target_feat_ex["InceptionV3/Mixed_7a"] - # feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) - # feat_loss = tf.reduce_mean(feat_square_diff) * 0.5 - # img_feat_err = tf.reduce_mean(feat_square_diff, axis=1) * 0.5 + gen_feat = gen_feat_ex["InceptionV3/Mixed_7a"] + target_feat = target_feat_ex["InceptionV3/Mixed_7a"] + feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) + feat_loss = tf.reduce_mean(feat_square_diff) * 0.334 + img_feat_err = tf.reduce_mean(feat_square_diff, axis=1) * 0.334 - # # gen_feat = gen_feat_ex["InceptionV3/Mixed_6b"] - # # target_feat = target_feat_ex["InceptionV3/Mixed_6b"] - # # feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) - # # feat_loss += tf.reduce_mean(feat_square_diff) * 0.16 - # # img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.16 + gen_feat = gen_feat_ex["InceptionV3/Mixed_7b"] + target_feat = target_feat_ex["InceptionV3/Mixed_7b"] + feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) + feat_loss += tf.reduce_mean(feat_square_diff) * 0.333 + img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.333 + + gen_feat = gen_feat_ex["InceptionV3/Mixed_7c"] + target_feat = target_feat_ex["InceptionV3/Mixed_7c"] + feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) + feat_loss += tf.reduce_mean(feat_square_diff) * 0.333 + img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.333 # # gen_feat = gen_feat_ex["InceptionV3/Mixed_5a"] # # target_feat = target_feat_ex["InceptionV3/Mixed_5a"] @@ -251,11 +257,11 @@ if params.features: # # img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.17 # conv1 1, conv1 2, conv3 2 and conv4 2 - gen_feat = gen_feat_ex["InceptionV3/Conv2d_1a_3x3"] - target_feat = target_feat_ex["InceptionV3/Conv2d_1a_3x3"] - feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) - feat_loss = tf.reduce_mean(feat_square_diff) * 0.5 - img_feat_err = tf.reduce_mean(feat_square_diff, axis=1) * 0.5 + # gen_feat = gen_feat_ex["InceptionV3/Conv2d_1a_3x3"] + # target_feat = target_feat_ex["InceptionV3/Conv2d_1a_3x3"] + # feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) + # feat_loss = tf.reduce_mean(feat_square_diff) * 0.5 + # img_feat_err = tf.reduce_mean(feat_square_diff, axis=1) * 0.5 # gen_feat = gen_feat_ex["InceptionV3/Conv2d_2a_3x3"] # target_feat = target_feat_ex["InceptionV3/Conv2d_2a_3x3"] @@ -275,11 +281,11 @@ if params.features: # feat_loss += tf.reduce_mean(feat_square_diff) * 0.25 # img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.25 - gen_feat = gen_feat_ex["InceptionV3/Mixed_7a"] - target_feat = target_feat_ex["InceptionV3/Mixed_7a"] - feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) - feat_loss += tf.reduce_mean(feat_square_diff) * 0.5 - img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.5 + # gen_feat = gen_feat_ex["InceptionV3/Mixed_7a"] + # target_feat = target_feat_ex["InceptionV3/Mixed_7a"] + # feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) + # feat_loss += tf.reduce_mean(feat_square_diff) * 0.5 + # img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) * 0.5 else: feat_loss = tf.constant(0.0) -- cgit v1.2.3-70-g09d2