sxhxliang / detectron2_backbone

detectron2 backbone: resnet18, efficientnet, hrnet, mobilenet v2, resnest, bifpn
211 stars 41 forks source link

Configs for EfficientNet B0x FPN #10

Closed ioangatop closed 1 year ago

ioangatop commented 3 years ago

Hi there! First I have to say thank you for your amazing work and contribution 😁.

Here is the configuration file that I use for the Faster RCNN EfficientNet B0 FPN;

File faster_rcnn_EfficientNet_B0_FPN.yaml:

MODEL:
  META_ARCHITECTURE: "GeneralizedRCNN"
  MASK_ON: False
  WEIGHTS: "https://github.com/lukemelas/EfficientNet-PyTorch/releases/download/1.0/efficientnet-b0-355c32eb.pth"
  BACKBONE:
    NAME: "build_efficientnet_fpn_backbone"
    FREEZE_AT: 0
  EFFICIENTNET:
    NAME: "efficientnet_b0" # efficientnet_b1, efficientnet_2,  ..., efficientnet_b7
    FEATURE_INDICES: [1, 4, 10, 15]
    OUT_FEATURES: ["stride4", "stride8", "stride16", "stride32"]
  FPN:
    IN_FEATURES: ["stride4", "stride8", "stride16", "stride32"]
  ANCHOR_GENERATOR:
    SIZES: [[32], [64], [128], [256], [512]]  # One size for each in feature map
    ASPECT_RATIOS: [[0.5, 1.0, 2.0]]  # Three aspect ratios (same for all in feature maps)
  RPN:
    IN_FEATURES: ["p2", "p3", "p4", "p5", "p6"]
    PRE_NMS_TOPK_TRAIN: 2000  # Per FPN level
    PRE_NMS_TOPK_TEST: 1000  # Per FPN level
    # Detectron1 uses 2000 proposals per-batch,
    # (See "modeling/rpn/rpn_outputs.py" for details of this legacy issue)
    # which is approximately 1000 proposals per-image since the default batch size for FPN is 2.
    POST_NMS_TOPK_TRAIN: 1000
    POST_NMS_TOPK_TEST: 1000
  ROI_HEADS:
    NAME: "StandardROIHeads"
    IN_FEATURES: ["p2", "p3", "p4", "p5"]
  ROI_BOX_HEAD:
    NAME: "FastRCNNConvFCHead"
    NUM_FC: 2
    POOLER_RESOLUTION: 7
  ROI_MASK_HEAD:
    NAME: "MaskRCNNConvUpsampleHead"
    NUM_CONV: 4
    POOLER_RESOLUTION: 14
DATASETS:
  TRAIN: ("coco_2017_train",)
  TEST: ("coco_2017_val",)
SOLVER:
  IMS_PER_BATCH: 16
  BASE_LR: 0.02
  STEPS: (60000, 80000)
  MAX_ITER: 90000
INPUT:
  MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800)
VERSION: 2

However, replacing the NAME with, for example, efficientnet_b1, It yields a mismatch on the dimensions during training, as the out features of the backbone does not much exactly those of the FPN.

I will really appreciate if you (or anyone!) can help me with that, thanks!

VGrondin commented 3 years ago

Thanks for the .yaml example! Ever found out how to do that? And are the models pre-trained?

JanGlinko commented 2 years ago

Any solution?

EDIT: b6 is working

zhuzhu512 commented 2 years ago

Any solution?

EDIT: b6 is working 怎么改的啊?

ammarmuflih commented 1 year ago

have you found a solution?