Пример #1
0
 def _anchor_component(self, height, width):
     anchors, anchor_length = generate_anchors_pre(height, width,
                                                   self._feat_stride,
                                                   self._anchor_scales,
                                                   self._anchor_ratios)
     self._anchors = Variable(torch.from_numpy(anchors).cuda())
     self._anchor_length = anchor_length
  def generate_anchors(self, im_info):
      height = int(math.ceil(im_info[0, 0] / np.float32(self._feat_stride[0])))
      width = int(math.ceil(im_info[0, 1] / np.float32(self._feat_stride[0])))
      anchors, anchor_length = generate_anchors_pre(height, width, self._feat_stride, self._anchor_scales, self._anchor_ratios)
 
      anchors = np.reshape(anchors, [-1, 4])
      anchor_length = np.reshape(anchor_length, [-1])
      return anchors, anchor_length
Пример #3
0
 def _anchor_component(self, height, width):
   # just to get the shape right
   #height = int(math.ceil(self._im_info.data[0, 0] / self._feat_stride[0]))
   #width = int(math.ceil(self._im_info.data[0, 1] / self._feat_stride[0]))
   anchors, anchor_length = generate_anchors_pre(\
                                         height, width,
                                          self._feat_stride, self._anchor_scales, self._anchor_ratios)
   self._anchors = Variable(torch.from_numpy(anchors).cuda())
   self._anchor_length = anchor_length
Пример #4
0
 def _anchor_component(self, height, width):
   # just to get the shape right
   #height = int(math.ceil(self._im_info.data[0, 0] / self._feat_stride[0]))
   #width = int(math.ceil(self._im_info.data[0, 1] / self._feat_stride[0]))
   anchors, anchor_length = generate_anchors_pre(\
                                         height, width,
                                          self._feat_stride, self._anchor_scales, self._anchor_ratios)
   self._anchors = Variable(torch.from_numpy(anchors).cuda())
   self._anchor_length = anchor_length
Пример #5
0
 def _anchor_component(self, height, width):
     # just to get the shape right
     # 找出anchorbox,是合成的读取的图片的height和width
     #height = int(math.ceil(self._im_info.data[0, 0] / self._feat_stride[0]))
     #width = int(math.ceil(self._im_info.data[0, 1] / self._feat_stride[0]))
     #转到snippets。py
     anchors, anchor_length = generate_anchors_pre(\
                                           height, width,
                                            self._feat_stride, self._anchor_scales, self._anchor_ratios)
     #得到9×k个anchor,送到GPU
     self._anchors = torch.from_numpy(anchors).to(self._device)
     self._anchor_length = anchor_length
Пример #6
0
 def _anchor_component(self):
     with tf.variable_scope('ANCHOR_' + self._tag) as scope:
         # just to get the shape right
         height = tf.to_int32(
             tf.ceil(self._im_info[0] / np.float32(self._feat_stride[0])))
         width = tf.to_int32(
             tf.ceil(self._im_info[1] / np.float32(self._feat_stride[0])))
         anchors, anchor_length = generate_anchors_pre(
             height, width, self._feat_stride, self._anchor_scales,
             self._anchor_ratios)
         anchors.set_shape([None, 4])
         anchor_length.set_shape([])
         self._anchors = anchors
         self._anchor_length = anchor_length
Пример #7
0
 def _anchor_component(self):
   with tf.variable_scope('ANCHOR_' + self._tag) as scope:
     # just to get the shape right
     height = tf.to_int32(tf.ceil(self._im_info[0] / np.float32(self._feat_stride[0])))
     width = tf.to_int32(tf.ceil(self._im_info[1] / np.float32(self._feat_stride[0])))
     anchors, anchor_length = generate_anchors_pre(
       height,
       width,
       self._feat_stride,
       self._anchor_scales,
       self._anchor_ratios
     )
     anchors.set_shape([None, 4])
     anchor_length.set_shape([])
     self._anchors = anchors
     self._anchor_length = anchor_length
Пример #8
0
    def _anchor_component_fpn(self, net_conv):
        # just to get the shape right
        #height = int(math.ceil(self._im_info.data[0, 0] / self._feat_stride[0]))
        #width = int(math.ceil(self._im_info.data[0, 1] / self._feat_stride[0]))
        anchors_total = []
        anchor_length_total = []
        for idx, p in enumerate(net_conv):
            height = p.size(2)
            width = p.size(3)
            anchors, anchor_length = generate_anchors_pre(\
                                                  height, width,
                                                   [self._feat_stride[idx]], [self._anchor_scales[idx]], self._anchor_ratios)
            anchors_total.append(Variable(torch.from_numpy(anchors).cuda()))
            anchor_length_total.append(anchor_length)

        self._anchors = anchors_total
        self._anchor_length = anchor_length_total
Пример #9
0
import tensorflow as tf
import numpy as np
from layer_utils import snippets


if __name__ == '__main__':
    anchors, length = snippets.generate_anchors_pre(40, 60, 16)
    print(anchors[:32, :])
    print(length)
Пример #10
0
import tensorflow as tf
import numpy as np
from layer_utils import snippets

if __name__ == '__main__':
    anchors, length = snippets.generate_anchors_pre(40, 60, 16)
    print(anchors[:32, :])
    print(length)