def roidb(self, target_hash, targets=[], every_k_frames=1, verbose=True, skip_empty=True):
"""
@param target_hash: target hash map (name -> unique id)
@param targets: return only provided target names
Returns (img, bbox, targets [hashed with target_hash (int32)])
"""
self.check_ground_truth_availability()
if every_k_frames > 1 and skip_empty:
raise RuntimeError('roidb not meant for skipping frames,'
'and skipping empty simultaneously ')
# Iterate through all images
for idx, (t,ch,data) in enumerate(self.iterframes()):
# Skip every k frames, if requested
if idx % every_k_frames != 0:
continue
# Annotations may be empty, if
# unlabeled, however we can request
# to yield if its empty or not
bboxes = data.annotation.bboxes
if not len(bboxes) and skip_empty:
continue
target_names = data.annotation.pretty_names
if len(targets):
inds, = np.where([np.any([t in name for t in targets]) for name in target_names])
target_names = [target_names[ind] for ind in inds]
bboxes = bboxes[inds]
yield (data.img, bboxes, np.int32(map(lambda key: target_hash.get(key, -1), target_names)))
评论列表
文章目录