def reset(self):
self.cur = 0
if self.shuffle:
if config.TRAIN.ASPECT_GROUPING:
widths = np.array([r['width'] for r in self.roidb])
heights = np.array([r['height'] for r in self.roidb])
horz = (widths >= heights)
vert = np.logical_not(horz)
horz_inds = np.where(horz)[0]
vert_inds = np.where(vert)[0]
inds = np.hstack((np.random.permutation(horz_inds), np.random.permutation(vert_inds)))
if inds.shape[0] % 2:
inds_ = np.reshape(inds[:-1], (-1, 2))
row_perm = np.random.permutation(np.arange(inds_.shape[0]))
inds[:-1] = np.reshape(inds_[row_perm, :], (-1, ))
else:
inds = np.reshape(inds, (-1, 2))
row_perm = np.random.permutation(np.arange(inds.shape[0]))
inds = np.reshape(inds[row_perm, :], (-1, ))
self.index = inds
else:
np.random.shuffle(self.index)
评论列表
文章目录