class_docstr: Create a PaddleDetection-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:`dict`, optional):
          Extra configuration passed to the PaddleDetection model configuration.
          Defaults to `{}`.
          Including arguments:
          enable_mkldnn (:obj:`bool`, optional):
              Whether use mkldnn to accelerate the computation.
              Defaults to False.
          thread_num (:obj:`int`, optional):
              The number of threads.
              Defaults to 10.
          threshold (:obj:`float`, optional):
              Threshold to reserve the result for output.
              Defaults to 0.5.
          target_size (:obj:`list`, optional):
              The image shape after resize.
              Defaults to [640,640].
  
  Examples::
      >>> import layoutparser as lp
      >>> model = lp.models.PaddleDetectionLayoutModel('
                                  lp://PubLayNet/ppyolov2_r50vd_dcn_365e/config')
      >>> model.detect(image)
class_docstr_tok: ["Create","a","PaddleDetection-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",":","`","dict","`",",","optional",")",":","Extra","configuration","passed","to","the","PaddleDetection","model","configuration",".","Defaults","to","`","{","}","`",".","Including","arguments",":","enable_mkldnn","(",":","obj",":","`","bool","`",",","optional",")",":","Whether","use","mkldnn","to","accelerate","the","computation",".","Defaults","to","False",".","thread_num","(",":","obj",":","`","int","`",",","optional",")",":","The","number","of","threads",".","Defaults","to","10.","threshold","(",":","obj",":","`","float","`",",","optional",")",":","Threshold","to","reserve","the","result","for","output",".","Defaults","to","0.5.","target_size","(",":","obj",":","`","list","`",",","optional",")",":","The","image","shape","after","resize",".","Defaults","to","[","640,640","]",".","Examples",":",":",">",">",">","import","layoutparser","as","lp",">",">",">","model","=","lp.models.PaddleDetectionLayoutModel","(","'","lp",":","\/\/PubLayNet\/ppyolov2_r50vd_dcn_365e\/config","'",")",">",">",">","model.detect","(","image",")"]
docstr: set AnalysisConfig, generate AnalysisPredictor
  Args:
      model_dir (str): root path of __model__ and __params__
      device (str): cuda or cpu
  Returns:
      predictor (PaddlePredictor): AnalysisPredictor
  Raises:
      ValueError: predict by TensorRT need enforce_cpu == False.
docstr_tok: ["set","AnalysisConfig",",","generate","AnalysisPredictor","Args",":","model_dir","(","str",")",":","root","path","of","__model__","and","__params__","device","(","str",")",":","cuda","or","cpu","Returns",":","predictor","(","PaddlePredictor",")",":","AnalysisPredictor","Raises",":","ValueError",":","predict","by","TensorRT","need","enforce_cpu","==","False","."]
code: def load_predictor(
      self,
      model_dir,
      device=None,
      enable_mkldnn=False,
      thread_num=10,
  ):
      """set AnalysisConfig, generate AnalysisPredictor
      Args:
          model_dir (str): root path of __model__ and __params__
          device (str): cuda or cpu
      Returns:
          predictor (PaddlePredictor): AnalysisPredictor
      Raises:
          ValueError: predict by TensorRT need enforce_cpu == False.
      """
  
      config = paddle.inference.Config(
          os.path.join(
              model_dir, "inference.pdmodel"
          ),  # TODO: Move them to some constants
          os.path.join(model_dir, "inference.pdiparams"),
      )
  
      if device == "cuda":
          # initial GPU memory(M), device ID
          # 2000 is an appropriate value for PaddleDetection model
          config.enable_use_gpu(2000, 0)
          # optimize graph and fuse op
          config.switch_ir_optim(True)
      else:
          config.disable_gpu()
          config.set_cpu_math_library_num_threads(thread_num)
          if enable_mkldnn:
              config.enable_mkldnn()
              try:
                  # cache 10 different shapes for mkldnn to avoid memory leak
                  config.set_mkldnn_cache_capacity(10)
                  config.enable_mkldnn()
              except Exception as e:
                  print(
                      "The current environment does not support `mkldnn`, so disable mkldnn."
                  )
  
      # disable print log when predict
      config.disable_glog_info()
      # enable shared memory
      config.enable_memory_optim()
      # disable feed, fetch OP, needed by zero_copy_run
      config.switch_use_feed_fetch_ops(False)
      predictor = paddle.inference.create_predictor(config)
      return predictor
  
file_path: layout-parser/src/layoutparser/models/paddledetection/layoutmodel.py
imports: from typing import List, Union, Dict, Any, Tuple
  import os
  from functools import reduce
  import warnings
  from PIL import Image
  import cv2
  import numpy
  from .catalog import PathManager, LABEL_MAP_CATALOG, MODEL_CATALOG
  from ..base_layoutmodel import BaseLayoutModel
  from ...elements import Rectangle, TextBlock, Layout
  from ...file_utils import is_paddle_available
label_desc: Use image node_id 2 for calling the PaddleDetectionLayoutModel obj's underlying member method code with example usage: obj.load_predictor(model_dir, device, enable_mkldnn, thread_num) and returns: predictor