class_docstr: Implementation of the ObjectSeeker certifiable robust defense applied to object detection models.
  The original implementation is https://github.com/inspire-group/ObjectSeeker
  
  | Paper link: https://arxiv.org/abs/2202.01811
class_docstr_tok: ["Implementation","of","the","ObjectSeeker","certifiable","robust","defense","applied","to","object","detection","models",".","The","original","implementation","is","https",":","\/\/github.com\/inspire-group\/ObjectSeeker","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2202.01811"]
docstr: Create an ObjectSeeker classifier.
  
  :param model: Object detection model. The output of the model is `List[Dict[str, torch.Tensor]]`,
                one for each input image. The fields of the Dict are as follows:
  
                - boxes [N, 4]: the boxes in [x1, y1, x2, y2] format, with 0 <= x1 < x2 <= W and
                  0 <= y1 < y2 <= H.
                - labels [N]: the labels for each image.
                - scores [N]: the scores of each prediction.
  :param input_shape: The shape of one input sample.
  :param optimizer: The optimizer for training the classifier.
  :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
         maximum values allowed for features. If floats are provided, these will be used as the range of all
         features. If arrays are provided, each value will be considered the bound for a feature, thus
         the shape of clip values needs to match the total number of features.
  :param channels_first: Set channels first or last.
  :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
  :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
  :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
         used for data preprocessing. The first value will be subtracted from the input. The input will then
         be divided by the second one.
  :param attack_losses: Tuple of any combination of strings of loss components: 'loss_classifier', 'loss_box_reg',
                        'loss_objectness', and 'loss_rpn_box_reg'.
  :param detector_type: The type of object detector being used: 'YOLO' | 'Faster-RCNN'
  :param num_lines: The number of divisions both vertically and horizontally to make masked predictions.
  :param confidence_threshold: The confidence threshold to discard bounding boxes.
  :param iou_threshold: The IoU threshold to discard overlapping bounding boxes.
  :param prune_threshold: The IoA threshold for pruning and duplicated bounding boxes.
  :param epsilon: The maximum distance between bounding boxes when merging using DBSCAN.
  :param device_type: Type of device to be used for model and tensors, if `cpu` run on CPU, if `gpu` run on GPU
                      if available otherwise run on CPU.
  :param verbose: Show progress bars.
docstr_tok: ["Create","an","ObjectSeeker","classifier",".",":","param","model",":","Object","detection","model",".","The","output","of","the","model","is","`","List","[","Dict","[","str",",","torch.Tensor","]","]","`",",","one","for","each","input","image",".","The","fields","of","the","Dict","are","as","follows",":","-","boxes","[","N",",","4","]",":","the","boxes","in","[","x1",",","y1",",","x2",",","y2","]","format",",","with","0","<","=","x1","<","x2","<","=","W","and","0","<","=","y1","<","y2","<","=","H.","-","labels","[","N","]",":","the","labels","for","each","image",".","-","scores","[","N","]",":","the","scores","of","each","prediction",".",":","param","input_shape",":","The","shape","of","one","input","sample",".",":","param","optimizer",":","The","optimizer","for","training","the","classifier",".",":","param","clip_values",":","Tuple","of","the","form","`","(","min",",","max",")","`","of","floats","or","`","np.ndarray","`","representing","the","minimum","and","maximum","values","allowed","for","features",".","If","floats","are","provided",",","these","will","be","used","as","the","range","of","all","features",".","If","arrays","are","provided",",","each","value","will","be","considered","the","bound","for","a","feature",",","thus","the","shape","of","clip","values","needs","to","match","the","total","number","of","features",".",":","param","channels_first",":","Set","channels","first","or","last",".",":","param","preprocessing_defences",":","Preprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","postprocessing_defences",":","Postprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","preprocessing",":","Tuple","of","the","form","`","(","subtrahend",",","divisor",")","`","of","floats","or","`","np.ndarray","`","of","values","to","be","used","for","data","preprocessing",".","The","first","value","will","be","subtracted","from","the","input",".","The","input","will","then","be","divided","by","the","second","one",".",":","param","attack_losses",":","Tuple","of","any","combination","of","strings","of","loss","components",":","'loss_classifier","'",",","'loss_box_reg","'",",","'loss_objectness","'",",","and","'loss_rpn_box_reg","'",".",":","param","detector_type",":","The","type","of","object","detector","being","used",":","'YOLO","'","|","'Faster-RCNN'",":","param","num_lines",":","The","number","of","divisions","both","vertically","and","horizontally","to","make","masked","predictions",".",":","param","confidence_threshold",":","The","confidence","threshold","to","discard","bounding","boxes",".",":","param","iou_threshold",":","The","IoU","threshold","to","discard","overlapping","bounding","boxes",".",":","param","prune_threshold",":","The","IoA","threshold","for","pruning","and","duplicated","bounding","boxes",".",":","param","epsilon",":","The","maximum","distance","between","bounding","boxes","when","merging","using","DBSCAN",".",":","param","device_type",":","Type","of","device","to","be","used","for","model","and","tensors",",","if","`","cpu","`","run","on","CPU",",","if","`","gpu","`","run","on","GPU","if","available","otherwise","run","on","CPU",".",":","param","verbose",":","Show","progress","bars","."]
code: def __init__(
      self,
      model: "torch.nn.Module",
      input_shape: Tuple[int, ...] = (3, 416, 416),
      optimizer: Optional["torch.optim.Optimizer"] = None,
      clip_values: Optional["CLIP_VALUES_TYPE"] = None,
      channels_first: Optional[bool] = True,
      preprocessing_defences: Union[
          "Preprocessor", List["Preprocessor"], None
      ] = None,
      postprocessing_defences: Union[
          "Postprocessor", List["Postprocessor"], None
      ] = None,
      preprocessing: "PREPROCESSING_TYPE" = None,
      attack_losses: Tuple[str, ...] = (
          "loss_classifier",
          "loss_box_reg",
          "loss_objectness",
          "loss_rpn_box_reg",
      ),
      detector_type: Literal["YOLO", "Faster-RCNN"] = "YOLO",
      num_lines: int = 3,
      confidence_threshold: float = 0.3,
      iou_threshold: float = 0.5,
      prune_threshold: float = 0.5,
      epsilon: float = 0.1,
      device_type: str = "gpu",
      verbose: bool = False,
  ):
      """
      Create an ObjectSeeker classifier.
  
      :param model: Object detection model. The output of the model is `List[Dict[str, torch.Tensor]]`,
                    one for each input image. The fields of the Dict are as follows:
  
                    - boxes [N, 4]: the boxes in [x1, y1, x2, y2] format, with 0 <= x1 < x2 <= W and
                      0 <= y1 < y2 <= H.
                    - labels [N]: the labels for each image.
                    - scores [N]: the scores of each prediction.
      :param input_shape: The shape of one input sample.
      :param optimizer: The optimizer for training the classifier.
      :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
             maximum values allowed for features. If floats are provided, these will be used as the range of all
             features. If arrays are provided, each value will be considered the bound for a feature, thus
             the shape of clip values needs to match the total number of features.
      :param channels_first: Set channels first or last.
      :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
      :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
      :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
             used for data preprocessing. The first value will be subtracted from the input. The input will then
             be divided by the second one.
      :param attack_losses: Tuple of any combination of strings of loss components: 'loss_classifier', 'loss_box_reg',
                            'loss_objectness', and 'loss_rpn_box_reg'.
      :param detector_type: The type of object detector being used: 'YOLO' | 'Faster-RCNN'
      :param num_lines: The number of divisions both vertically and horizontally to make masked predictions.
      :param confidence_threshold: The confidence threshold to discard bounding boxes.
      :param iou_threshold: The IoU threshold to discard overlapping bounding boxes.
      :param prune_threshold: The IoA threshold for pruning and duplicated bounding boxes.
      :param epsilon: The maximum distance between bounding boxes when merging using DBSCAN.
      :param device_type: Type of device to be used for model and tensors, if `cpu` run on CPU, if `gpu` run on GPU
                          if available otherwise run on CPU.
      :param verbose: Show progress bars.
      """
      super().__init__(
          model=model,
          clip_values=clip_values,
          channels_first=channels_first,
          preprocessing_defences=preprocessing_defences,
          postprocessing_defences=postprocessing_defences,
          preprocessing=preprocessing,
          device_type=device_type,
          num_lines=num_lines,
          confidence_threshold=confidence_threshold,
          iou_threshold=iou_threshold,
          prune_threshold=prune_threshold,
          epsilon=epsilon,
          verbose=verbose,
      )
  
      self._input_shape = input_shape
      self._optimizer = optimizer
      self._attack_losses = attack_losses
      self.detector_type = detector_type
  
      self.detector: Union[
          PyTorchYolo, PyTorchFasterRCNN, PyTorchObjectDetector
      ]
      if detector_type == "YOLO":
          self.detector = PyTorchYolo(
              model=model,
              input_shape=input_shape,
              optimizer=optimizer,
              clip_values=clip_values,
              channels_first=channels_first,
              preprocessing_defences=preprocessing_defences,
              postprocessing_defences=postprocessing_defences,
              preprocessing=preprocessing,
              attack_losses=attack_losses,
              device_type=device_type,
          )
      elif detector_type == "Faster-RCNN":
          self.detector = PyTorchFasterRCNN(
              model=model,
              input_shape=input_shape,
              optimizer=optimizer,
              clip_values=clip_values,
              channels_first=channels_first,
              preprocessing_defences=preprocessing_defences,
              postprocessing_defences=postprocessing_defences,
              preprocessing=preprocessing,
              attack_losses=attack_losses,
              device_type=device_type,
          )
      else:
          self.detector = PyTorchObjectDetector(
              model=model,
              input_shape=input_shape,
              optimizer=optimizer,
              clip_values=clip_values,
              channels_first=channels_first,
              preprocessing_defences=preprocessing_defences,
              postprocessing_defences=postprocessing_defences,
              preprocessing=preprocessing,
              attack_losses=attack_losses,
              device_type=device_type,
          )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import sys
  from typing import List, Dict, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from art.estimators.certification.object_seeker.object_seeker import ObjectSeekerMixin
  from art.estimators.object_detection import ObjectDetectorMixin, PyTorchObjectDetector, PyTorchFasterRCNN, PyTorchYolo
  from art.estimators.pytorch import PyTorchEstimator
label_desc: Use image node_id 1 to create a new PyTorchObjectSeeker object from inherited base classes: ObjectSeekerMixin, ObjectDetectorMixin, PyTorchEstimator with example: obj = PyTorchObjectSeeker(model, input_shape, optimizer, clip_values, channels_first, preprocessing_defences, postprocessing_defences, preprocessing, attack_losses, detector_type, num_lines, confidence_threshold, iou_threshold, prune_threshold, epsilon, device_type, verbose)