Skip to content

Commit

Permalink
Prevent filtering of empty images (#1424)
Browse files Browse the repository at this point in the history
* Update data.py

* Update data.py

* Update config.py

* Update data.py

* Update data.py
  • Loading branch information
mdv3101 committed Apr 15, 2020
1 parent 92aab65 commit 963e510
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/FasterRCNN/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def __ne__(self, _):
# whether the coordinates in your registered dataset are
# absolute pixel values in range [0, W or H] or relative values in [0, 1]
_C.DATA.ABSOLUTE_COORD = True
# Filter Negative Samples from dataset
_C.DATA.FILTER_EMPTY_ANNOTATIONS = True
# Number of data loading workers.
# In case of horovod training, this is the number of workers per-GPU (so you may want to use a smaller number).
# Set to 0 to disable parallel data loading
Expand Down
3 changes: 2 additions & 1 deletion examples/FasterRCNN/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ def get_train_dataflow():
# Filter out images that have no gt boxes, but this filter shall not be applied for testing.
# The model does support training with empty images, but it is not useful for COCO.
num = len(roidbs)
roidbs = list(filter(lambda img: len(img["boxes"][img["is_crowd"] == 0]) > 0, roidbs))
if cfg.DATA.FILTER_EMPTY_ANNOTATIONS:
roidbs = list(filter(lambda img: len(img["boxes"][img["is_crowd"] == 0]) > 0, roidbs))
logger.info(
"Filtered {} images which contain no non-crowd groudtruth boxes. Total #images for training: {}".format(
num - len(roidbs), len(roidbs)
Expand Down

0 comments on commit 963e510

Please sign in to comment.