Python nets.inception_utils.inception_arg_scope() Examples
The following are 2
code examples of nets.inception_utils.inception_arg_scope().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
nets.inception_utils
, or try the search function
.
Example #1
Source File: inception.py From vehicle-triplet-reid with MIT License | 5 votes |
def endpoints(image, is_training): if image.get_shape().ndims != 4: raise ValueError('Input must be of size [batch, height, width, 3]') image = image - tf.constant(_RGB_MEAN, dtype=tf.float32, shape=(1,1,1,3)) with tf.contrib.slim.arg_scope(inception_arg_scope(batch_norm_decay=0.9, weight_decay=0.0002)): _, endpoints = inception_v4(image, num_classes=None, is_training=is_training) print('endpoints: {}'.format(endpoints)) endpoints['model_output'] = endpoints['global_pool'] = tf.reduce_mean( endpoints['Mixed_7d'], [1, 2], name='pool5', keep_dims=False) return endpoints, 'InceptionV4'
Example #2
Source File: model.py From ICPR_TextDection with GNU General Public License v3.0 | 4 votes |
def model(images, weight_decay=1e-5, is_training=True): images = mean_image_subtraction(images) with slim.arg_scope(inception_arg_scope(weight_decay=weight_decay)): logits, end_points = inception_resnet_v2(images, num_classes=None, is_training=is_training) for key in end_points.keys(): print(key, end_points[key]) return logits, end_points # print(end_points.keys()) # with tf.variable_scope('feature_fusion', values=[end_points.values()]): # batch_norm_params = { # 'decay': 0.997, # 'epsilon': 1e-5, # 'scale': True, # 'is_training': is_training # } # with slim.arg_scope([slim.conv2d], activation_fn=tf.nn.relu, normalizer_fn=slim.batch_norm, # normalizer_params=batch_norm_params, weights_regularizer=slim.l2_regularizer(weight_decay)): # f = [end_points['Scale-5'], # 16 # end_points['Scale-4'], # 32 # end_points['Scale-3'], # 64 # end_points['Scale-2'], # 128 # end_points['Scale-1']] # 256 # g = [None, None, None, None, None] # h = [None, None, None, None, None] # num_outputs = [None, 1024, 128, 64, 32] # for i in range(5): # if i == 0: # h[i] = f[i] # else: # # 相当于一个融合,减少维度的过程,kernel size等于1 # c1_1 = slim.conv2d(tf.concat([g[i-1], f[i]], axis=-1), num_outputs=num_outputs[i], kernel_size=1) # h[i] = slim.conv2d(c1_1, num_outputs=num_outputs[i], kernel_size=3) # if i <= 3: # g[i] = unpool(h[i]) # # g[i] = slim.conv2d(g[i], num_outputs[i + 1], 1) # # g[i] = slim.conv2d(g[i], num_outputs[i + 1], 3) # else: # g[i] = slim.conv2d(h[i], num_outputs[i], 3) # print("Shape of f_{} {}, h_{} {}, g_{} {}".format(i, f[i].shape, i, h[i].shape, i, g[i].shape)) # F_score = slim.conv2d(g[3], 1, 1, activation_fn=tf.nn.sigmoid, normalizer_fn=None) # if FLAGS.geometry == 'RBOX': # # 4 channel of axis aligned bbox and 1 channel rotation angle # print 'RBOX' # geo_map = slim.conv2d(g[4], 4, 1, activation_fn=tf.nn.sigmoid, normalizer_fn=None) * FLAGS.text_scale # angle_map = (slim.conv2d(g[4], 1, 1, activation_fn=tf.nn.sigmoid, # normalizer_fn=None) - 0.5) * np.pi / 2 # angle is between [-45, 45] # F_geometry = tf.concat([geo_map, angle_map], axis=-1) # else: # # LD modify # # concated_score_map = tf.concat([F_score, g[3]], axis=-1) # # F_geometry = slim.conv2d(g[4], 8, 1, activation_fn=parametric_relu, # # normalizer_fn=None) * FLAGS.text_scale # assert False # return F_score, F_geometry