def model(this, inputs, is_training): ''' define the model, we use slim's implemention of resnet ''' with tf.variable_scope(this.vscope): base_network = nets_factory.get_network_fn( this.network_name, num_classes=2, weight_decay=this.weight_decay, is_training=is_training) logits, end_points = base_network(inputs[0]) f = [ end_points['pool5'], end_points['pool4'], end_points['pool3'], end_points['pool2'] ] values = None #end_points.value; # with slim.arg_scope(resnet_v1.resnet_arg_scope(weight_decay=weight_decay)): # logits, end_points = resnet_v1.resnet_v1_50(images, is_training=is_training, scope='resnet_v1_50') g = welf_slime_unpool().model(f, is_training, values=values, weight_decay=this.weight_decay) return welf_slime_east_parser().model( g, is_training, values=values, weight_decay=this.weight_decay, text_scale=this.text_scale)
def testGetNetworkFnSecondHalf(self): batch_size = 5 num_classes = 1000 for net in nets_factory.networks_map.keys()[10:]: with tf.Graph().as_default() as g, self.test_session(g): net_fn = nets_factory.get_network_fn(net, num_classes) # Most networks use 224 as their default_image_size image_size = getattr(net_fn, 'default_image_size', 224) inputs = tf.random_uniform( (batch_size, image_size, image_size, 3)) logits, end_points = net_fn(inputs) self.assertTrue(isinstance(logits, tf.Tensor)) self.assertTrue(isinstance(end_points, dict)) self.assertEqual(logits.get_shape().as_list()[0], batch_size) self.assertEqual(logits.get_shape().as_list()[-1], num_classes)