question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom dataset without segmentations

See original GitHub issue

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:

  1. Use annotation['segmenation'] = 0 and annotation['area'] = bbox_height * bbox_width (and of course leaving TRAIN.GT_MIN_AREA = -1)
  2. 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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

16reactions
ir413commented, Jan 28, 2018

Hi @learnbott, I think it may be simpler and less error-prone to preprocess your json annotations to include the following entries:

'segmentation': []
'area': box_width * box_height
'iscrowd': 0

I believe this would allow you to perform training (w/ flipping) without any modifications to the code.

1reaction
learnbottcommented, Jan 29, 2018

Much appreciated!

On Sat, Jan 27, 2018 at 4:51 PM, Ilija Radosavovic <notifications@github.com

wrote:

Hi @learnbott https://github.com/learnbott, I think it may be simpler and less error-prone to preprocess your json annotations to include the following entries:

‘segmentation’ : [] ‘area’: box_width * box_height ‘iscrowd’: 0

I believe this would allow you to perform training (w/ flipping) without any modifications to the code.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebookresearch/Detectron/issues/48#issuecomment-361028870, or mute the thread https://github.com/notifications/unsubscribe-auth/AT56PcRoCdEUiJC9NZudU7-GZy0dPVhjks5tO8R_gaJpZM4RvF6T .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fine-Tune a Semantic Segmentation Model with a Custom ...
This guide shows how you can fine-tune Segformer, a state-of-the-art semantic segmentation model. Our goal is to build a model for a pizza ......
Read more >
How I Created a Dataset for Instance Segmentation ... - MLWhiz
This post is about creating your own custom dataset for Image Segmentation/Object Detection. So, Why Not OID or any other dataset on the ......
Read more >
2: Train with customized datasets
2: Train with customized datasets. In this note, you will know how to inference, test, and train predefined models with customized datasets.
Read more >
How to Train YOLOv5 Instance Segmentation with Custom Data
This blog will walk through how to train YOLOv5 for instance segmentation on a custom dataset.
Read more >
Custom Instance Segmentation Training With 7 Lines Of Code.
The steps required to train a custom model. ... STEP1: Prepare your dataset: Our goal is to create a model that can perform...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found