예제 #1
0
def anchors_plane(height, width, stride=1.0, **kwargs):
    """Get a complete set of anchors in a spatial plane,
  height, width are plane dimensions
  stride is scale ratio of
  """
    # TODO: implement in C, or pre-compute them, or set to a fixed input-shape
    # enum all anchors in a plane
    scales = kwargs.setdefault('scales', [2, 4, 8, 16, 32])
    ratios = kwargs.setdefault('ratios', [0.5, 1, 2.0])
    base = kwargs.setdefault('base', 16)
    anc = anchors(scales, ratios, base)
    all_anchors = cython_anchor.anchors_plane(height, width, stride, anc)
    return all_anchors
예제 #2
0
def anchors_plane(height, width, stride = 1.0, 
        scales=[2, 4, 8, 16, 32], ratios=[0.5, 1, 2.0], base=16):
  """Get a complete set of anchors in a spatial plane,
  height, width are plane dimensions
  stride is scale ratio of
  """
  # TODO: implement in C, or pre-compute them, or set to a fixed input-shape
  # enum all anchors in a plane
  # scales = kwargs.setdefault('scales', [2, 4, 8, 16, 32])
  # ratios = kwargs.setdefault('ratios', [0.5, 1, 2.0])
  # base = kwargs.setdefault('base', 16)
  anc = anchors(scales, ratios, base)
  all_anchors = cython_anchor.anchors_plane(height, width, stride, anc)
  return all_anchors
예제 #3
0
def anchors_plane(height,
                  width,
                  stride=1.0,
                  scales=[2., 4., 8., 16., 32.],
                  ratios=[0.5, 1, 2.0],
                  base=16,
                  anchor_shift=[[0.0, 0.0]]):
    """Get a complete set of anchors in a spatial plane,
  height, width are plane dimensions
  stride is scale ratio of
  """
    # TODO: implement in C, or pre-compute them, or set to a fixed input-shape
    # enum all anchors in a plane
    # scales = kwargs.setdefault('scales', [2, 4, 8, 16, 32])
    # ratios = kwargs.setdefault('ratios', [0.5, 1, 2.0])
    # base = kwargs.setdefault('base', 16)
    anc = anchors(scales, ratios, base).astype(np.float)
    anchor_shift = np.array(anchor_shift, dtype=np.float)
    all_anchors = cython_anchor.anchors_plane(height, width, stride, anc,
                                              anchor_shift)
    return all_anchors
예제 #4
0
        ret[inds, :] = data
    return ret


if __name__ == '__main__':
    import time

    t = time.time()
    a = anchors()
    num_anchors = 0

    # all_anchors = anchors_plane(200, 250, stride=4, boarder=0)
    # num_anchors += all_anchors.shape[0]
    for i in range(10):
        ancs = anchors()
        all_anchors = cython_anchor.anchors_plane(200, 250, 4, ancs)
        num_anchors += all_anchors.shape[0] * all_anchors.shape[
            1] * all_anchors.shape[2]
        all_anchors = cython_anchor.anchors_plane(100, 125, 8, ancs)
        num_anchors += all_anchors.shape[0] * all_anchors.shape[
            1] * all_anchors.shape[2]
        all_anchors = cython_anchor.anchors_plane(50, 63, 16, ancs)
        num_anchors += all_anchors.shape[0] * all_anchors.shape[
            1] * all_anchors.shape[2]
        all_anchors = cython_anchor.anchors_plane(25, 32, 32, ancs)
        num_anchors += all_anchors.shape[0] * all_anchors.shape[
            1] * all_anchors.shape[2]
    print('average time: %f' % ((time.time() - t) / 10))
    print('anchors: %d' % (num_anchors / 10))
    print(a.shape, '\n', a)
    # from IPython import embed
예제 #5
0
    ret = np.empty((count,) + data.shape[1:], dtype=np.float32)
    ret.fill(fill)
    ret[inds, :] = data
  return ret

if __name__ == '__main__':
  import time
  
  t = time.time()
  a = anchors()
  num_anchors = 0

  # all_anchors = anchors_plane(200, 250, stride=4, boarder=0)
  # num_anchors += all_anchors.shape[0]
  for i in range(10):
    ancs = anchors()
    all_anchors = cython_anchor.anchors_plane(200, 250, 4, ancs)
    num_anchors += all_anchors.shape[0] * all_anchors.shape[1] * all_anchors.shape[2]
    all_anchors = cython_anchor.anchors_plane(100, 125, 8, ancs)
    num_anchors += all_anchors.shape[0] * all_anchors.shape[1] * all_anchors.shape[2]
    all_anchors = cython_anchor.anchors_plane(50, 63, 16, ancs)
    num_anchors += all_anchors.shape[0] * all_anchors.shape[1] * all_anchors.shape[2]
    all_anchors = cython_anchor.anchors_plane(25, 32, 32, ancs)
    num_anchors += all_anchors.shape[0] * all_anchors.shape[1] * all_anchors.shape[2]
  print('average time: %f' % ((time.time() - t) / 10))
  print('anchors: %d' % (num_anchors / 10))
  print(a.shape, '\n', a)
  print (all_anchors.shape)
  # from IPython import embed
  # embed()