class_docstr: Base class for two-stage detectors.
  
  Two-stage detectors typically consisting of a region proposal network and a
  task-specific regression head.
class_docstr_tok: ["Base","class","for","two-stage","detectors",".","Two-stage","detectors","typically","consisting","of","a","region","proposal","network","and","a","task-specific","regression","head","."]
code: def __init__(
      self,
      backbone,
      neck=None,
      rpn_head=None,
      roi_head=None,
      train_cfg=None,
      test_cfg=None,
      pretrained=None,
  ):
      super(TwoStageDetector, self).__init__()
      self.backbone = build_backbone(backbone)
  
      if neck is not None:
          self.neck = build_neck(neck)
  
      if rpn_head is not None:
          rpn_train_cfg = (
              train_cfg.rpn if train_cfg is not None else None
          )
          rpn_head_ = rpn_head.copy()
          rpn_head_.update(
              train_cfg=rpn_train_cfg, test_cfg=test_cfg.rpn
          )
          self.rpn_head = build_head(rpn_head_)
  
      if roi_head is not None:
          # update train and test cfg here for now
          # TODO: refactor assigner & sampler
          rcnn_train_cfg = (
              train_cfg.rcnn if train_cfg is not None else None
          )
          roi_head.update(train_cfg=rcnn_train_cfg)
          roi_head.update(test_cfg=test_cfg.rcnn)
          self.roi_head = build_head(roi_head)
  
      self.train_cfg = train_cfg
      self.test_cfg = test_cfg
  
      self.init_weights(pretrained=pretrained)
  
file_path: insightface/detection/scrfd/mmdet/models/detectors/two_stage.py
imports: import torch
  import torch.nn
  from ..builder import DETECTORS, build_backbone, build_head, build_neck
  from .base import BaseDetector
label_desc: Use image node_id 1 to create a new TwoStageDetector object from inherited base classes: BaseDetector with example: obj = TwoStageDetector(backbone, neck, rpn_head, roi_head, train_cfg, test_cfg, pretrained)