in siammot/data/image_dataset.py [0:0]
def _check_load_bbox(self, entry, instance_id):
"""
Check and load ground-truth labels
"""
entry_id = entry['id']
entry_id = [entry_id] if not isinstance(entry_id, (list, tuple)) else entry_id
ann_ids = self.dataset.getAnnIds(imgIds=entry_id, iscrowd=None)
objs = self.dataset.loadAnns(ann_ids)
# check valid bboxes
valid_objs = []
width = entry['width']
height = entry['height']
_instance_count = 0
_redudant_count = 0
_amodal_count = 0
unique_bbs = set()
for obj in objs:
if obj.get('ignore', 0) == 1:
continue
if not self._use_crowd and obj.get('iscrowd', 0):
continue
if self._amodal:
xmin, ymin, xmax, ymax = bbox_xywh_to_xyxy(obj['bbox'])
if xmin < 0 or ymin < 0 or xmax > width or ymax > height:
_amodal_count += 1
else:
xmin, ymin, xmax, ymax = bbox_clip_xyxy(bbox_xywh_to_xyxy(obj['bbox']), width, height)
if (xmin, ymin, xmax, ymax) in unique_bbs:
_redudant_count += 1
continue
box_w = (xmax - xmin)
box_h = (ymax - ymin)
area = box_w * box_h
if area <= self._min_object_area:
continue
# require non-zero box area
if xmax > xmin and ymax > ymin:
unique_bbs.add((xmin, ymin, xmax, ymax))
contiguous_cid = self.json_category_id_to_contiguous_id[obj['category_id']]
valid_objs.append([xmin, ymin, xmax, ymax, contiguous_cid,
instance_id+_instance_count])
_instance_count += 1
if not valid_objs:
if not self._skip_empty:
# dummy invalid labels if no valid objects are found
valid_objs.append([-1, -1, -1, -1, -1, -1])
return valid_objs, _instance_count, _redudant_count, _amodal_count