docstr: DBNet text detector class
  
  Parameters
  ----------
  backbone : str, optional
      Backbone to use. Options are "resnet18" and "resnet50". The default is "resnet18".
  weight_dir : str, optional
      Path to directory that contains weight files. If set to None, the path will be set
      to "../weights/". The default is None.
  weight_name : str, optional
      Name of the weight to use as specified in DBNet_inference.yaml or a filename 
      in weight_dir. The default is 'pretrained'.
  initialize_model : Boolean, optional
      If True, construct the model and load weight at class initialization.
      Otherwise, only initial the class without constructing the model.
      The default is True.
  dynamic_import_relative_path : str, optional
      Relative path to 'model/detector.py'. This option is for supporting
      integrating this module into other modules. For example, easyocr/DBNet
      This should be left as None when calling this module as a standalone. 
      The default is None.
  device : str, optional
      Device to use. Options are "cuda" and "cpu". The default is 'cuda'.
  verbose : int, optional
      Verbosity level. The default is 0.
  
  Raises
  ------
  ValueError
      Raised when backbone is invalid.
  FileNotFoundError
      Raised when weight file is not found.
  
  Returns
  -------
  None.
docstr_tok: ["DBNet","text","detector","class","Parameters","--","--","--","--","--","backbone",":","str",",","optional","Backbone","to","use",".","Options","are","``","resnet18","''","and","``","resnet50","''",".","The","default","is","``","resnet18","''",".","weight_dir",":","str",",","optional","Path","to","directory","that","contains","weight","files",".","If","set","to","None",",","the","path","will","be","set","to","``","..","\/weights\/","''",".","The","default","is","None",".","weight_name",":","str",",","optional","Name","of","the","weight","to","use","as","specified","in","DBNet_inference.yaml","or","a","filename","in","weight_dir",".","The","default","is","'pretrained","'",".","initialize_model",":","Boolean",",","optional","If","True",",","construct","the","model","and","load","weight","at","class","initialization",".","Otherwise",",","only","initial","the","class","without","constructing","the","model",".","The","default","is","True",".","dynamic_import_relative_path",":","str",",","optional","Relative","path","to","'model\/detector.py","'",".","This","option","is","for","supporting","integrating","this","module","into","other","modules",".","For","example",",","easyocr\/DBNet","This","should","be","left","as","None","when","calling","this","module","as","a","standalone",".","The","default","is","None",".","device",":","str",",","optional","Device","to","use",".","Options","are","``","cuda","''","and","``","cpu","''",".","The","default","is","'cuda","'",".","verbose",":","int",",","optional","Verbosity","level",".","The","default","is","0",".","Raises","--","--","--","ValueError","Raised","when","backbone","is","invalid",".","FileNotFoundError","Raised","when","weight","file","is","not","found",".","Returns","--","--","--","-","None","."]
code: def __init__(
      self,
      backbone="resnet18",
      weight_dir=None,
      weight_name="pretrained",
      initialize_model=True,
      dynamic_import_relative_path=None,
      device="cuda",
      verbose=0,
  ):
      """
      DBNet text detector class
  
      Parameters
      ----------
      backbone : str, optional
          Backbone to use. Options are "resnet18" and "resnet50". The default is "resnet18".
      weight_dir : str, optional
          Path to directory that contains weight files. If set to None, the path will be set
          to "../weights/". The default is None.
      weight_name : str, optional
          Name of the weight to use as specified in DBNet_inference.yaml or a filename
          in weight_dir. The default is 'pretrained'.
      initialize_model : Boolean, optional
          If True, construct the model and load weight at class initialization.
          Otherwise, only initial the class without constructing the model.
          The default is True.
      dynamic_import_relative_path : str, optional
          Relative path to 'model/detector.py'. This option is for supporting
          integrating this module into other modules. For example, easyocr/DBNet
          This should be left as None when calling this module as a standalone.
          The default is None.
      device : str, optional
          Device to use. Options are "cuda" and "cpu". The default is 'cuda'.
      verbose : int, optional
          Verbosity level. The default is 0.
  
      Raises
      ------
      ValueError
          Raised when backbone is invalid.
      FileNotFoundError
          Raised when weight file is not found.
  
      Returns
      -------
      None.
      """
      self.device = device
  
      config_path = os.path.join(
          os.path.dirname(__file__), "configs", "DBNet_inference.yaml"
      )
      with open(config_path, "r") as fid:
          self.configs = yaml.safe_load(fid)
  
      if dynamic_import_relative_path is not None:
          self.configs = self.set_relative_import_path(
              self.configs, dynamic_import_relative_path
          )
  
      if backbone in self.configs.keys():
          self.backbone = backbone
      else:
          raise ValueError(
              "Invalid backbone. Current support backbone are {}.".format(
                  ",".join(self.configs.keys())
              )
          )
  
      if weight_dir is not None:
          self.weight_dir = weight_dir
      else:
          self.weight_dir = os.path.join(
              os.path.dirname(__file__), "weights"
          )
  
      if initialize_model:
          if weight_name in self.configs[backbone]["weight"].keys():
              weight_path = os.path.join(
                  self.weight_dir,
                  self.configs[backbone]["weight"][weight_name],
              )
              error_message = "A weight with a name {} is found in DBNet_inference.yaml but cannot be find file: {}."
          else:
              weight_path = os.path.join(self.weight_dir, weight_name)
              error_message = "A weight with a name {} is not found in DBNet_inference.yaml and cannot be find file: {}."
  
          if not os.path.isfile(weight_path):
              raise FileNotFoundError(
                  error_message.format(weight_name, weight_path)
              )
  
          self.initialize_model(
              self.configs[backbone]["model"], weight_path
          )
  
      else:
          self.model = None
  
      self.BGR_MEAN = np.array(self.configs["BGR_MEAN"])
      self.min_detection_size = self.configs["min_detection_size"]
      self.max_detection_size = self.configs["max_detection_size"]
  
imports: import os
  import math
  import yaml
  from shapely.geometry import Polygon
  import PIL.Image
  import numpy
  import cv2
  import pyclipper
  import torch
  from .model.constructor import Configurable
label_desc: Use image node_id 1 to create a new DBNet object  with example: obj = DBNet(backbone, weight_dir, weight_name, initialize_model, dynamic_import_relative_path, device, verbose)