class_docstr: Create a Detectron2-based Layout Detection Model
  
  Args:
      config_path (:obj:`str`):
          The path to the configuration file.
      model_path (:obj:`str`, None):
          The path to the saved weights of the model.
          If set, overwrite the weights in the configuration file.
          Defaults to `None`.
      label_map (:obj:`dict`, optional):
          The map from the model prediction (ids) to real
          word labels (strings). If the config is from one of the supported
          datasets, Layout Parser will automatically initialize the label_map.
          Defaults to `None`.
      device(:obj:`str`, optional):
          Whether to use cuda or cpu devices. If not set, LayoutParser will
          automatically determine the device to initialize the models on.
      extra_config (:obj:`list`, optional):
          Extra configuration passed to the Detectron2 model
          configuration. The argument will be used in the `merge_from_list
          <https://detectron2.readthedocs.io/modules/config.html
          #detectron2.config.CfgNode.merge_from_list>`_ function.
          Defaults to `[]`.
  
  Examples::
      >>> import layoutparser as lp
      >>> model = lp.Detectron2LayoutModel('lp://HJDataset/faster_rcnn_R_50_FPN_3x/config')
      >>> model.detect(image)
code: def __init__(
      self,
      config_path,
      model_path=None,
      label_map=None,
      extra_config=None,
      enforce_cpu=None,
      device=None,
  ):
      if enforce_cpu is not None:
          warnings.warn(
              "Setting enforce_cpu is deprecated. Please set `device` instead.",
              DeprecationWarning,
          )
  
      if extra_config is None:
          extra_config = []
  
      config_path, model_path = self.config_parser(
          config_path, model_path, allow_empty_path=True
      )
      config_path = PathManager.get_local_path(config_path)
  
      if label_map is None:
          if config_path.startswith("lp://"):
              dataset_name = config_path.lstrip("lp://").split("/")[1]
              label_map = LABEL_MAP_CATALOG[dataset_name]
          else:
              label_map = {}
  
      cfg = detectron2.config.get_cfg()
      cfg.merge_from_file(config_path)
      cfg.merge_from_list(extra_config)
  
      if model_path is not None:
          model_path = PathManager.get_local_path(model_path)
          # Because it will be forwarded to the detectron2 paths
          cfg.MODEL.WEIGHTS = model_path
  
      if is_torch_cuda_available():
          if device is None:
              device = "cuda"
      else:
          device = "cpu"
      cfg.MODEL.DEVICE = device
  
      self.cfg = cfg
  
      self.label_map = label_map
      self._create_model()
  
file_path: layout-parser/src/layoutparser/models/detectron2/layoutmodel.py
imports: from typing import Union
  from PIL import Image
  import numpy
  import warnings
  from .catalog import MODEL_CATALOG, PathManager, LABEL_MAP_CATALOG
  from ..base_layoutmodel import BaseLayoutModel
  from ...elements import Rectangle, TextBlock, Layout
  from ...file_utils import is_torch_cuda_available, is_detectron2_available
label_desc: Use image node_id 1 to create a new Detectron2LayoutModel object from inherited base classes: BaseLayoutModel with example: obj = Detectron2LayoutModel(config_path, model_path, label_map, extra_config, enforce_cpu, device)