Commit 21ae9538 authored by Hang Zhang's avatar Hang Zhang Committed by Facebook GitHub Bot
Browse files

Try LSJ on Faster RCNN with FBNet

Summary: Try LSJ with Faster RCNN with FBNet backbone

Reviewed By: newstzpz

Differential Revision: D32054932

fbshipit-source-id: 4fdb30e7b1258d6f167f2c2fd331209aad1b599a
parent c12469c2
MODEL:
META_ARCHITECTURE: "GeneralizedRCNN"
MASK_ON: False
FBNET_V2:
ARCH: "FBNetV3_A"
NORM: "naiveSyncBN"
WIDTH_DIVISOR: 8
BACKBONE:
NAME: FBNetV2C4Backbone
ANCHOR_GENERATOR:
# SIZES: [[32, 64, 128, 256, 512]] # NOTE: for smaller resolution (320 < 512)
SIZES: [[32, 64, 96, 128, 160]]
ASPECT_RATIOS: [[0.5, 1.0, 2.0]] # Three aspect ratios (same for all in feature maps)
RPN:
HEAD_NAME: FBNetV2RpnHead
IN_FEATURES: ["trunk3"]
# Default values are 12000/2000 for train and 6000/1000 for test. In FBNet
# we use smaller numbers. TODO: reduce proposals for test in .yaml directly.
PRE_NMS_TOPK_TRAIN: 2000
POST_NMS_TOPK_TRAIN: 2000
PRE_NMS_TOPK_TEST: 1000
POST_NMS_TOPK_TEST: 30
ROI_HEADS:
NAME: StandardROIHeads
IN_FEATURES: ["trunk3"]
ROI_BOX_HEAD:
NAME: FBNetV2RoIBoxHead
POOLER_RESOLUTION: 6
NORM: "naiveSyncBN"
ROI_MASK_HEAD:
NAME: "MaskRCNNConvUpsampleHead"
NUM_CONV: 4
POOLER_RESOLUTION: 14
MODEL_EMA:
ENABLED: True
DECAY: 0.9998
DATASETS:
TRAIN: ("coco_2017_train",)
TEST: ("coco_2017_val",)
SOLVER:
IMS_PER_BATCH: 32
BASE_LR: 0.16
MAX_ITER: 540000
LR_SCHEDULER_NAME: WarmupCosineLR
TEST:
EVAL_PERIOD: 10000
D2GO_DATA:
AUG_OPS:
TRAIN: [
'ResizeScaleOp::{"min_scale": 0.1, "max_scale": 2.0, "target_height": 224, "target_width": 320}',
"RandomFlipOp",
'FixedSizeCropOp::{"crop_size": [224, 320]}',
]
TEST: ["ResizeShortestEdgeOp"]
INPUT:
RECOMPUTE_BOXES: True
MAX_SIZE_TEST: 320
MAX_SIZE_TRAIN: 320
MIN_SIZE_TEST: 224
MIN_SIZE_TRAIN: (224,)
VERSION: 2
......@@ -3,7 +3,7 @@
import logging
from typing import List, Union
from typing import List, Union, Optional
import detectron2.data.transforms.augmentation as aug
from detectron2.config import CfgNode
......@@ -24,6 +24,8 @@ D2_RANDOM_TRANSFORMS = {
"RandomFlip": d2T.RandomFlip,
"RandomSaturation": d2T.RandomSaturation,
"RandomLighting": d2T.RandomLighting,
"FixedSizeCrop": d2T.FixedSizeCrop,
"ResizeScale": d2T.ResizeScale,
}
......@@ -105,3 +107,19 @@ def RandomSSDColorAugOp(
assert isinstance(kwargs, dict)
assert "img_format" not in kwargs
return [ColorAugSSDTransform(img_format=cfg.INPUT.FORMAT, **kwargs)]
# example repr: ResizeScaleOp::{"min_scale": 0.1, "max_scale": 2.0, "target_height": 1024, "target_width": 1024}
@TRANSFORM_OP_REGISTRY.register()
def ResizeScaleOp(
cfg: CfgNode, arg_str: Optional[str], is_train: bool
) -> List[aug.Augmentation]:
return build_func(cfg, arg_str, is_train, name="ResizeScale")
# example repr: FixedSizeCropOp::{"crop_size": [1024, 1024]}
@TRANSFORM_OP_REGISTRY.register()
def FixedSizeCropOp(
cfg: CfgNode, arg_str: Optional[str], is_train: bool
) -> List[aug.Augmentation]:
return build_func(cfg, arg_str, is_train, name="FixedSizeCrop")
......@@ -70,6 +70,9 @@ def get_default_cfg(_C):
_C.SOLVER.LR_MULTIPLIER_OVERWRITE = []
_C.SOLVER.WEIGHT_DECAY_EMBED = 0.0
# RECOMPUTE_BOXES for LSJ Training
_C.INPUT.RECOMPUTE_BOXES = False
# Default world size in D2 is 0, which means scaling is not applied. For D2Go
# auto scale is encouraged, setting it to 8
assert _C.SOLVER.REFERENCE_WORLD_SIZE == 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment