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","."]
docstr: Exchange bbox_head key to rpn_head key when loading single-stage
  weights into two-stage model.
docstr_tok: ["Exchange","bbox_head","key","to","rpn_head","key","when","loading","single-stage","weights","into","two-stage","model","."]
code: def _load_from_state_dict(
      self,
      state_dict: dict,
      prefix: str,
      local_metadata: dict,
      strict: bool,
      missing_keys: Union[List[str], str],
      unexpected_keys: Union[List[str], str],
      error_msgs: Union[List[str], str],
  ) -> None:
      """Exchange bbox_head key to rpn_head key when loading single-stage
      weights into two-stage model."""
      bbox_head_prefix = (
          prefix + ".bbox_head" if prefix else "bbox_head"
      )
      bbox_head_keys = [
          k for k in state_dict.keys() if k.startswith(bbox_head_prefix)
      ]
      rpn_head_prefix = prefix + ".rpn_head" if prefix else "rpn_head"
      rpn_head_keys = [
          k for k in state_dict.keys() if k.startswith(rpn_head_prefix)
      ]
      if len(bbox_head_keys) != 0 and len(rpn_head_keys) == 0:
          for bbox_head_key in bbox_head_keys:
              rpn_head_key = (
                  rpn_head_prefix
                  + bbox_head_key[len(bbox_head_prefix) :]
              )
              state_dict[rpn_head_key] = state_dict.pop(bbox_head_key)
      super()._load_from_state_dict(
          state_dict,
          prefix,
          local_metadata,
          strict,
          missing_keys,
          unexpected_keys,
          error_msgs,
      )
  
file_path: mmdetection/mmdet/models/detectors/two_stage.py
imports: import copy
  import warnings
  from typing import List, Tuple, Union
  import torch
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig
  from .base import BaseDetector
label_desc: Use image node_id 2 for calling the TwoStageDetector obj's underlying member method code with example usage: obj._load_from_state_dict(state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs) without return types