diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-02-16 11:16:27 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-02-16 11:16:27 +0100 |
| commit | 20feb8038ede472d5004615034ec03f23a378c48 (patch) | |
| tree | a627b2fde999bf41a041a25ec134392de3577c38 /cli/app/search/search_dense.py | |
| parent | 6aec6ad6a3d371ba5e07f2ae98fdb520eb86bac4 (diff) | |
scope
Diffstat (limited to 'cli/app/search/search_dense.py')
| -rw-r--r-- | cli/app/search/search_dense.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/cli/app/search/search_dense.py b/cli/app/search/search_dense.py index e5769ab..b2e05a4 100644 --- a/cli/app/search/search_dense.py +++ b/cli/app/search/search_dense.py @@ -566,8 +566,8 @@ def feature_loss_tfhub(feature_extractor, opt_feature_layers, BATCH_SIZE, img_a, img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) return feat_loss / len(opt_feature_layers), img_feat_err / len(opt_feature_layers) -scope_index = 0 -vgg_model = tf.make_template('vgg16', nets.vgg.vgg_16, is_training=False) +# scope_index = 0 +# vgg_model = tf.make_template('vgg16', nets.vgg.vgg_16, is_training=False) def feature_loss_vgg(feature_extractor, opt_feature_layers, BATCH_SIZE, img_a, img_b, y, x, height, width, resize_height=None, resize_width=None): height = int(height) width = int(width) @@ -585,26 +585,27 @@ def feature_loss_vgg(feature_extractor, opt_feature_layers, BATCH_SIZE, img_a, i img_b = tf.image.resize_images(img_b, [resize_height, resize_width]) global scope_index - scope_index += 1 + # scope_index += 1 # scope_a = 'vgg_16_{}_a'.format(scope_index) # scope_b = 'vgg_16_{}_b'.format(scope_index) - scope_a = 'vgg_16' - scope_b = 'vgg_16' + # scope_a = 'vgg_16' + # scope_b = 'vgg_16' # gen_fc, gen_feat_ex = nets.vgg.vgg_16(img_a, scope=scope_a) #, reuse=True) # target_fc, target_feat_ex = nets.vgg.vgg_16(img_b, scope=scope_b) #, reuse=True) - gen_fc, gen_feat_ex = vgg_model(img_a) #, reuse=True) - target_fc, target_feat_ex = vgg_model(img_b) #, reuse=True) + with slim.arg_scope(nets.vgg.vgg_arg_scope()): + gen_fc, gen_feat_ex = vgg.vgg_16(img_a) #, reuse=True) + target_fc, target_feat_ex = vgg.vgg_16(img_b) #, reuse=True) # gen_feat_ex = feature_extractor(dict(images=img_a), as_dict=True, signature='image_feature_vector') # target_feat_ex = feature_extractor(dict(images=img_b), as_dict=True, signature='image_feature_vector') - feat_loss = tf.constant(0.0) - img_feat_err = tf.constant(0.0) + feat_loss = tf.constant(0.0) + img_feat_err = tf.constant(0.0) - for layer_name in opt_feature_layers: - gen_feat = gen_feat_ex[scope_a + '/' + layer_name] - target_feat = target_feat_ex[scope_b + '/' + layer_name] - feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) - feat_loss += tf.reduce_mean(feat_square_diff) - img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) - return feat_loss / len(opt_feature_layers), img_feat_err / len(opt_feature_layers) + for layer_name in opt_feature_layers: + gen_feat = gen_feat_ex[scope_a + '/' + layer_name] + target_feat = target_feat_ex[scope_b + '/' + layer_name] + feat_square_diff = tf.reshape(tf.square(gen_feat - target_feat), [BATCH_SIZE, -1]) + feat_loss += tf.reduce_mean(feat_square_diff) + img_feat_err += tf.reduce_mean(feat_square_diff, axis=1) + return feat_loss / len(opt_feature_layers), img_feat_err / len(opt_feature_layers) |
