Created
December 17, 2017 10:06
-
-
Save Giribushan/6df730bd5b9b852dad97183afcbf99aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_pyramid(net_name, end_points, bilinear=True): | |
"""build pyramid features from a typical network, | |
assume each stage is 2 time larger than its top feature | |
Returns: | |
returns several endpoints | |
""" | |
pyramid = {} | |
if isinstance(net_name, str): | |
pyramid_map = _networks_map[net_name] | |
else: | |
pyramid_map = net_name | |
# pyramid['inputs'] = end_points['inputs'] | |
#arg_scope = _extra_conv_arg_scope() | |
arg_scope = _extra_conv_arg_scope_with_bn() | |
with tf.variable_scope('pyramid'): | |
with slim.arg_scope(arg_scope): | |
pyramid['P5'] = \ | |
slim.conv2d(end_points[pyramid_map['C5']], 256, [1, 1], stride=1, scope='C5') | |
for c in range(4, 1, -1): | |
s, s_ = pyramid['P%d'%(c+1)], end_points[pyramid_map['C%d' % (c)]] | |
# s_ = slim.conv2d(s_, 256, [3, 3], stride=1, scope='C%d'%c) | |
up_shape = tf.shape(s_) | |
# out_shape = tf.stack((up_shape[1], up_shape[2])) | |
# s = slim.conv2d(s, 256, [3, 3], stride=1, scope='C%d'%c) | |
s = tf.image.resize_bilinear(s, [up_shape[1], up_shape[2]], name='C%d/upscale'%c) | |
s_ = slim.conv2d(s_, 256, [1,1], stride=1, scope='C%d'%c) | |
s = tf.add(s, s_, name='C%d/addition'%c) | |
s = slim.conv2d(s, 256, [3,3], stride=1, scope='C%d/fusion'%c) | |
pyramid['P%d'%(c)] = s | |
return pyramid | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment