From 21771bbb0d7381ebd657a2397a9da1a8b9e2abc4 Mon Sep 17 00:00:00 2001 From: iKrishneel Date: Sun, 23 May 2021 20:52:42 +0900 Subject: [PATCH] updated the head and hyperparameters --- efficient_net_v2/build.py | 1 + efficient_net_v2/config/effnet_coco.yaml | 34 +++++++++++++++-------- efficient_net_v2/datasets/coco_dataset.py | 6 ++-- efficient_net_v2/model/backbone.py | 1 - 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/efficient_net_v2/build.py b/efficient_net_v2/build.py index 5d4ad85..0f7eaaa 100644 --- a/efficient_net_v2/build.py +++ b/efficient_net_v2/build.py @@ -198,6 +198,7 @@ def main(args): register_dataset(dataset_name='coco_2017_val_20', is_train=False) trainer = Trainer(cfg) + # trainer = DefaultTrainer(cfg) trainer.resume_or_load(resume=args.resume) return trainer.train() diff --git a/efficient_net_v2/config/effnet_coco.yaml b/efficient_net_v2/config/effnet_coco.yaml index 279f576..76a0410 100644 --- a/efficient_net_v2/config/effnet_coco.yaml +++ b/efficient_net_v2/config/effnet_coco.yaml @@ -11,12 +11,17 @@ MODEL: IN_FEATURES: ["s2", "s3", "s5", "s6"] RPN: IN_FEATURES: ["p2", "p3", "p4", "p5"] - PRE_NMS_TOPK_TRAIN: 12000 - POST_NMS_TOPK_TRAIN: 1000 + PRE_NMS_TOPK_TRAIN: 2000 + POST_NMS_TOPK_TRAIN: 1000 + CONV_DIMS: [256, 512, 256] PROPOSAL_GENERATOR: - NAME: "RPN" + NAME: "RPN" + MIN_SIZE: 4 + ANCHOR_GENERATOR: + SIZES: [[32], [64], [256], [512]] + ASPECT_RATIOS: [[0.5, 1.0, 2.0]] RETINANET: - NUM_CLASSES: &num_classes 20 + NUM_CLASSES: &num_classes 80 IOU_THRESHOLDS: [0.4, 0.5] IOU_LABELS: [0, -1, 1] SMOOTH_L1_LOSS_BETA: 0.0 @@ -26,8 +31,8 @@ MODEL: NAME: "StandardROIHeads" ROI_BOX_HEAD: NAME: "FastRCNNConvFCHead" - NUM_FC: 2 - NUM_CONV: 1 + NUM_FC: 0 + NUM_CONV: 3 NORM: "" POOLER_RESOLUTION: 7 ROI_MASK_HEAD: @@ -41,19 +46,24 @@ MODEL: SEM_SEG_HEAD: NUM_CLASSES: *num_classes MASK_ON: False - LOAD_PROPOSALS: False + LOAD_PROPOSALS: False WEIGHTS: "" SOLVER: - IMS_PER_BATCH: 12 - BASE_LR: 0.0005 - STEPS: (60000, 800000) + AMP: + ENABLED: True + IMS_PER_BATCH: 20 + BASE_LR: 0.02 + STEPS: (30000, 60000) MAX_ITER: 100000 + NESTEROV: False WARMUP_ITERS: 0 CHECKPOINT_PERIOD: 5000 DATALOADER: NUM_WORKERS: 8 DATASETS: - TRAIN: ("coco_2017_train_20", ) - TEST: ("coco_2017_val_20", ) + TRAIN: ("coco_2017_train", ) + TEST: ("coco_2017_val", ) + # PROPOSAL_FILES_TRAIN: ("detectron2://COCO-Detection/rpn_R_50_FPN_1x/137258492/coco_2017_train_box_proposals_21bc3a.pkl", ) + # PROPOSAL_FILES_TEST: ("detectron2://COCO-Detection/rpn_R_50_FPN_1x/137258492/coco_2017_val_box_proposals_ee0dad.pkl", ) # TRAIN: ("penn_fudan", ) # TEST: ("penn_fudan_test",) diff --git a/efficient_net_v2/datasets/coco_dataset.py b/efficient_net_v2/datasets/coco_dataset.py index 280fc40..d73873a 100644 --- a/efficient_net_v2/datasets/coco_dataset.py +++ b/efficient_net_v2/datasets/coco_dataset.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) -__labels__ = ( +LABELS = ( 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', @@ -35,7 +35,7 @@ def __post_init__(self): self.class_label = {} self.match_index = {} for i, line in enumerate(lines, 1): - if line not in __labels__: + if line not in LABELS: continue self.class_label[line] = i self.match_index[i] = [len(self.match_index) + 1, line] @@ -68,6 +68,6 @@ def __call__(self): import sys c = CocoDataset(coco_names=sys.argv[1]) - + import IPython IPython.embed() diff --git a/efficient_net_v2/model/backbone.py b/efficient_net_v2/model/backbone.py index f309486..aa51cf8 100644 --- a/efficient_net_v2/model/backbone.py +++ b/efficient_net_v2/model/backbone.py @@ -45,7 +45,6 @@ def output_shape(self): } def forward(self, x): - # return {'stage7': super().forward(x)} features = self.stage_forward(x) return { name: features[name] for name in self.out_features