Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 02723f2

Browse files
ynonaolgafacebook-github-bot
authored andcommitted
MinIoURandomCrop augmentation in d2go for detection models
Summary: X-link: https://github.com/fairinternal/detectron2/pull/589 X-link: facebookresearch/detectron2#4702 Pull Request resolved: #443 Add MinIoURandomCrop augmentation, compare model performance. Example of aug {F822053068}{F822053066}{F822053051} Data overhead is around 0.04 sec without aug {F822053812} with aug {F822053818} Reviewed By: zechenghe Differential Revision: D41804643 fbshipit-source-id: 8f13f98fa8132378a803534b59e892fbc1b3058c
1 parent 93301da commit 02723f2

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

d2go/data/dataset_mappers/d2go_dataset_mapper.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ def _original_call(self, dataset_dict):
104104
# pass additional arguments, will only be used when the Augmentation
105105
# takes `annotations` as input
106106
inputs.annotations = dataset_dict["annotations"]
107+
inputs.boxes = [
108+
utils.get_bbox(obj)
109+
for obj in dataset_dict["annotations"]
110+
if obj.get("iscrowd", 0) == 0
111+
]
107112
# Crop around an instance if there are instances in the image.
108113
if self.crop_gen:
109114
crop_tfm = utils.gen_crop_transform_with_instance(

d2go/data/transforms/d2_native.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"RandomResize": d2T.RandomResize,
2828
"FixedSizeCrop": d2T.FixedSizeCrop,
2929
"ResizeScale": d2T.ResizeScale,
30+
"MinIoURandomCrop": d2T.MinIoURandomCrop,
3031
}
3132

3233

@@ -118,6 +119,13 @@ def ResizeScaleOp(
118119
return build_func(cfg, arg_str, is_train, name="ResizeScale")
119120

120121

122+
@TRANSFORM_OP_REGISTRY.register()
123+
def MinIoURandomCropOp(
124+
cfg: CfgNode, arg_str: Optional[str], is_train: bool
125+
) -> List[aug.Augmentation]:
126+
return build_func(cfg, arg_str, is_train, name="MinIoURandomCrop")
127+
128+
121129
# example repr: FixedSizeCropOp::{"crop_size": [1024, 1024]}
122130
@TRANSFORM_OP_REGISTRY.register()
123131
def FixedSizeCropOp(

0 commit comments

Comments
 (0)