docstr: Init object detection/instance segmentation model.
  Args:
      model_path: str
          Path for the instance segmentation model weight
      config_path: str
          Path for the mmdetection instance segmentation model config file
      device: str
          Torch device, "cpu" or "cuda"
      mask_threshold: float
          Value to threshold mask pixels, should be between 0 and 1
      confidence_threshold: float
          All predictions with score < confidence_threshold will be discarded
      category_mapping: dict: str to str
          Mapping from category id (str) to category name (str) e.g. {"1": "pedestrian"}
      category_remapping: dict: str to int
          Remap category ids based on category names, after performing inference e.g. {"car": 3}
      load_at_init: bool
          If True, automatically loads the model at initalization
      image_size: int
          Inference input size.
docstr_tok: ["Init","object","detection\/instance","segmentation","model",".","Args",":","model_path",":","str","Path","for","the","instance","segmentation","model","weight","config_path",":","str","Path","for","the","mmdetection","instance","segmentation","model","config","file","device",":","str","Torch","device",",","``","cpu","''","or","``","cuda","''","mask_threshold",":","float","Value","to","threshold","mask","pixels",",","should","be","between","0","and","1","confidence_threshold",":","float","All","predictions","with","score","<","confidence_threshold","will","be","discarded","category_mapping",":","dict",":","str","to","str","Mapping","from","category","id","(","str",")","to","category","name","(","str",")","e.g",".","{","``","1","''",":","``","pedestrian","''","}","category_remapping",":","dict",":","str","to","int","Remap","category","ids","based","on","category","names",",","after","performing","inference","e.g",".","{","``","car","''",":","3","}","load_at_init",":","bool","If","True",",","automatically","loads","the","model","at","initalization","image_size",":","int","Inference","input","size","."]
code: def __init__(
      self,
      model_path: Optional[str] = None,
      model: Optional[Any] = None,
      config_path: Optional[str] = None,
      device: Optional[str] = None,
      mask_threshold: float = 0.5,
      confidence_threshold: float = 0.3,
      category_mapping: Optional[Dict] = None,
      category_remapping: Optional[Dict] = None,
      load_at_init: bool = True,
      image_size: int = None,
  ):
      """
      Init object detection/instance segmentation model.
      Args:
          model_path: str
              Path for the instance segmentation model weight
          config_path: str
              Path for the mmdetection instance segmentation model config file
          device: str
              Torch device, "cpu" or "cuda"
          mask_threshold: float
              Value to threshold mask pixels, should be between 0 and 1
          confidence_threshold: float
              All predictions with score < confidence_threshold will be discarded
          category_mapping: dict: str to str
              Mapping from category id (str) to category name (str) e.g. {"1": "pedestrian"}
          category_remapping: dict: str to int
              Remap category ids based on category names, after performing inference e.g. {"car": 3}
          load_at_init: bool
              If True, automatically loads the model at initalization
          image_size: int
              Inference input size.
      """
      self.model_path = model_path
      self.config_path = config_path
      self.model = None
      self.device = device
      self.mask_threshold = mask_threshold
      self.confidence_threshold = confidence_threshold
      self.category_mapping = category_mapping
      self.category_remapping = category_remapping
      self.image_size = image_size
      self._original_predictions = None
      self._object_prediction_list_per_image = None
  
      self.set_device()
  
      # automatically load model if load_at_init is True
      if load_at_init:
          if model:
              self.set_model(model)
          else:
              self.load_model()
  
file_path: sahi/sahi/models/base.py
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  from sahi.utils.import_utils import is_available
  from sahi.utils.torch import select_device
label_desc: Use image node_id 1 to create a new DetectionModel object  with example: obj = DetectionModel(model_path, model, config_path, device, mask_threshold, confidence_threshold, category_mapping, category_remapping, load_at_init, image_size)