Skip to content

Commit

Permalink
set FILTER_EMPTY_ANNOTATIONS to False for panoptic segmentation
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: fairinternal/detectron2#429

In the past we don't have this config option, so we use some heuristics in code.
It's better to set it explicitly now that we have an option.

Reviewed By: alexander-kirillov, bowenc0221

Differential Revision: D22370318

fbshipit-source-id: 269fdfbf146263ba416424a24da0ad987acd4475
  • Loading branch information
ppwwyyxx authored and facebook-github-bot committed Jul 3, 2020
1 parent d54c674 commit 45a4d97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions configs/COCO-PanopticSegmentation/Base-Panoptic-FPN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ MODEL:
DATASETS:
TRAIN: ("coco_2017_train_panoptic_separated",)
TEST: ("coco_2017_val_panoptic_separated",)
DATALOADER:
FILTER_EMPTY_ANNOTATIONS: False
4 changes: 2 additions & 2 deletions detectron2/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
_C.DATALOADER.SAMPLER_TRAIN = "TrainingSampler"
# Repeat threshold for RepeatFactorTrainingSampler
_C.DATALOADER.REPEAT_THRESHOLD = 0.0
# if True, the dataloader will filter out images that have no associated
# annotations at train time.
# Tf True, when working on datasets that have instance annotations, the
# training dataloader will filter out images without associated annotations
_C.DATALOADER.FILTER_EMPTY_ANNOTATIONS = True

# ---------------------------------------------------------------------------- #
Expand Down
7 changes: 4 additions & 3 deletions detectron2/data/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def get_detection_dataset_dicts(
`min_keypoints`. Set to 0 to do nothing.
proposal_files (list[str]): if given, a list of object proposal files
that match each dataset in `dataset_names`.
Returns:
list[dict]: a list of dicts following the standard dataset dict format.
"""
assert len(dataset_names)
dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in dataset_names]
Expand All @@ -228,10 +231,8 @@ def get_detection_dataset_dicts(
dataset_dicts = list(itertools.chain.from_iterable(dataset_dicts))

has_instances = "annotations" in dataset_dicts[0]
# Keep images without instance-level GT if the dataset has semantic labels.
if filter_empty and has_instances and "sem_seg_file_name" not in dataset_dicts[0]:
if filter_empty and has_instances:
dataset_dicts = filter_images_with_only_crowd_annotations(dataset_dicts)

if min_keypoints > 0 and has_instances:
dataset_dicts = filter_images_with_few_keypoints(dataset_dicts, min_keypoints)

Expand Down

0 comments on commit 45a4d97

Please sign in to comment.