当前位置: 首页>>代码示例>>Python>>正文


Python vgg.vgg_arg_scope方法代码示例

本文整理汇总了Python中nets.vgg.vgg_arg_scope方法的典型用法代码示例。如果您正苦于以下问题:Python vgg.vgg_arg_scope方法的具体用法?Python vgg.vgg_arg_scope怎么用?Python vgg.vgg_arg_scope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nets.vgg的用法示例。


在下文中一共展示了vgg.vgg_arg_scope方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: model

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_arg_scope [as 别名]
def model(image):
    image = mean_image_subtraction(image)
    with slim.arg_scope(vgg.vgg_arg_scope()):
        conv5_3 = vgg.vgg_16(image)

    rpn_conv = slim.conv2d(conv5_3, 512, 3)

    lstm_output = Bilstm(rpn_conv, 512, 128, 512, scope_name='BiLSTM')

    bbox_pred = lstm_fc(lstm_output, 512, 10 * 4, scope_name="bbox_pred")
    cls_pred = lstm_fc(lstm_output, 512, 10 * 2, scope_name="cls_pred")

    # transpose: (1, H, W, A x d) -> (1, H, WxA, d)
    cls_pred_shape = tf.shape(cls_pred)
    cls_pred_reshape = tf.reshape(cls_pred, [cls_pred_shape[0], cls_pred_shape[1], -1, 2])

    cls_pred_reshape_shape = tf.shape(cls_pred_reshape)
    cls_prob = tf.reshape(tf.nn.softmax(tf.reshape(cls_pred_reshape, [-1, cls_pred_reshape_shape[3]])),
                          [-1, cls_pred_reshape_shape[1], cls_pred_reshape_shape[2], cls_pred_reshape_shape[3]],
                          name="cls_prob")

    return bbox_pred, cls_pred, cls_prob 
开发者ID:zzzDavid,项目名称:ICDAR-2019-SROIE,代码行数:24,代码来源:model_train.py

示例2: _extract_proposal_features

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_arg_scope [as 别名]
def _extract_proposal_features(self, preprocessed_inputs, scope):
    if len(preprocessed_inputs.get_shape().as_list()) != 4:
      raise ValueError('`preprocessed_inputs` must be 4 dimensional, got a '
                       'tensor of shape %s' % preprocessed_inputs.get_shape())
    shape_assert = tf.Assert(
        tf.logical_and(
            tf.greater_equal(tf.shape(preprocessed_inputs)[1], 33),
            tf.greater_equal(tf.shape(preprocessed_inputs)[2], 33)),
        ['image size must at least be 33 in both height and width.'])

    with tf.control_dependencies([shape_assert]):
      with slim.arg_scope(
          vgg.vgg_arg_scope(weight_decay=self._weight_decay)):
        with tf.variable_scope(
            self._architecture, reuse=self._reuse_weights) as var_scope:
          _, endpoints = self._vgg_model(
              preprocessed_inputs,
              final_endpoint='conv5',
              trainable=self._is_training,
              freeze_layer=self._freeze_layer,
              scope=var_scope)

    handle = self._base_features
    return endpoints[handle] 
开发者ID:wonheeML,项目名称:mtl-ssl,代码行数:26,代码来源:faster_rcnn_vgg_16_feature_extractor.py

示例3: graph

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_arg_scope [as 别名]
def graph(x, y, i, x_max, x_min, grad):
  eps = FLAGS.max_epsilon
  num_iter = FLAGS.num_iter
  alpha = eps / num_iter
  momentum = FLAGS.momentum
  num_classes = 1000

  with slim.arg_scope(vgg.vgg_arg_scope()):
      logits, end_points = vgg.vgg_16(
          x, num_classes=num_classes, is_training=False)
            
  pred = tf.argmax(logits, 1)

  first_round = tf.cast(tf.equal(i, 0), tf.int64)
  y = first_round * pred + (1 - first_round) * y
  one_hot = tf.one_hot(y, num_classes)

  cross_entropy = tf.losses.softmax_cross_entropy(one_hot,
                                                  logits,
                                                  label_smoothing=0.0,
                                                  weights=1.0)
  noise = tf.gradients(cross_entropy, x)[0]
  noise = tf.nn.depthwise_conv2d(noise, stack_kernel, strides=[1, 1, 1, 1], padding='SAME')
  noise = noise / tf.reduce_mean(tf.abs(noise), [1,2,3], keep_dims=True)
  noise = momentum * grad + noise
  x = x + alpha * tf.sign(noise)
  x = tf.clip_by_value(x, x_min, x_max)
  i = tf.add(i, 1)
  return x, y, i, x_max, x_min, noise 
开发者ID:dongyp13,项目名称:Translation-Invariant-Attacks,代码行数:31,代码来源:attack_vgg16_mim.py

示例4: use_vgg16

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_arg_scope [as 别名]
def use_vgg16(self):
        
        with tf.Graph().as_default():
            image_size = vgg.vgg_16.default_image_size
            img_path = "../../data/misec_images/First_Student_IC_school_bus_202076.jpg"
            checkpoint_path = "../../data/trained_models/vgg16/vgg_16.ckpt"
            
            image_string = tf.read_file(img_path)
            image = tf.image.decode_jpeg(image_string, channels=3)
            processed_image = vgg_preprocessing.preprocess_image(image, image_size, image_size, is_training=False)
            processed_images  = tf.expand_dims(processed_image, 0)
            
            # Create the model, use the default arg scope to configure the batch norm parameters.
            with slim.arg_scope(vgg.vgg_arg_scope()):
                # 1000 classes instead of 1001.
                logits, _ = vgg.vgg_16(processed_images, num_classes=1000, is_training=False)
                probabilities = tf.nn.softmax(logits)
                
                init_fn = slim.assign_from_checkpoint_fn(
                    checkpoint_path,
                    slim.get_model_variables('vgg_16'))
                
                with tf.Session() as sess:
                    init_fn(sess)
                    np_image, probabilities = sess.run([image, probabilities])
                    probabilities = probabilities[0, 0:]
                    sorted_inds = [i[0] for i in sorted(enumerate(-probabilities), key=lambda x:x[1])]
                    self.disp_names(sorted_inds,probabilities,include_background=False)
                    
                plt.figure()
                plt.imshow(np_image.astype(np.uint8))
                plt.axis('off')
                plt.title(img_path)
                plt.show()
        return 
开发者ID:LevinJ,项目名称:SSD_tensorflow_VOC,代码行数:37,代码来源:pretrained.py

示例5: _extract_box_classifier_features

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_arg_scope [as 别名]
def _extract_box_classifier_features(self, proposal_feature_maps, scope):
    with tf.variable_scope(self._architecture, reuse=self._reuse_weights):
      with slim.arg_scope(
          vgg.vgg_arg_scope(weight_decay=self._weight_decay)):
          proposal_classifier_features = tf.identity(proposal_feature_maps)
    return proposal_classifier_features 
开发者ID:wonheeML,项目名称:mtl-ssl,代码行数:8,代码来源:faster_rcnn_vgg_16_feature_extractor.py


注:本文中的nets.vgg.vgg_arg_scope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。