This repository was archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
This repository was archived by the owner on Nov 21, 2023. It is now read-only.
Custom dataset without segmentations #48
Copy link
Copy link
Closed
Description
Is there a way to run a custom dataset that only has bounding boxes? I have the Wider Face dataset in COCO api json format, but it won't train without a segmentation
field in annotations
. I had to use two work arounds:
- Use
annotation['segmenation'] = 0
andannotation['area'] = bbox_height * bbox_width
(and of course leavingTRAIN.GT_MIN_AREA = -1
) - To allow
TRAIN.USE_FLIPPED = True
, Detectron/lib/datasets/roidb.py had to have some code commented out in this function:
def extend_with_flipped_entries(roidb, dataset):
"""Flip each entry in the given roidb and return a new roidb that is the
concatenation of the original roidb and the flipped entries.
"Flipping" an entry means that that image and associated metadata (e.g.,
ground truth boxes and object proposals) are horizontally flipped.
"""
flipped_roidb = []
for entry in roidb:
width = entry['width']
boxes = entry['boxes'].copy()
oldx1 = boxes[:, 0].copy()
oldx2 = boxes[:, 2].copy()
boxes[:, 0] = width - oldx2 - 1
boxes[:, 2] = width - oldx1 - 1
assert (boxes[:, 2] >= boxes[:, 0]).all()
flipped_entry = {}
dont_copy = ('boxes', 'segms', 'gt_keypoints', 'flipped')
for k, v in entry.items():
if k not in dont_copy:
flipped_entry[k] = v
flipped_entry['boxes'] = boxes
### commenting out to allow flipping for datasets without segmentations annotated
#flipped_entry['segms'] = segm_utils.flip_segms(
# entry['segms'], entry['height'], entry['width']
#)
if dataset.keypoints is not None:
flipped_entry['gt_keypoints'] = keypoint_utils.flip_keypoints(
dataset.keypoints, dataset.keypoint_flip_map,
entry['gt_keypoints'], entry['width']
)
flipped_entry['flipped'] = True
flipped_roidb.append(flipped_entry)
roidb.extend(flipped_roidb)
With those two adjustments the code runs beautifully. Is there a flag or config param that I am missing, or an easier way to run datasets with only bboxes?
Thank you for the code and the docker version!
AruniRC, vandesa003 and boulderdaze
Metadata
Metadata
Assignees
Labels
No labels