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: Checks if there is certifiable IoA robustness for each predicted bounding box.
  
  :param x: Sample input with shape as expected by the model.
  :param patch_size: The size of the patch to check against.
  :param offset: The offset to distinguish between the far and near patches.
  :return: A list containing an array of bools for each bounding box per image indicating if the bounding
           box is certified against the given patch.
docstr_tok: ["Checks","if","there","is","certifiable","IoA","robustness","for","each","predicted","bounding","box",".",":","param","x",":","Sample","input","with","shape","as","expected","by","the","model",".",":","param","patch_size",":","The","size","of","the","patch","to","check","against",".",":","param","offset",":","The","offset","to","distinguish","between","the","far","and","near","patches",".",":","return",":","A","list","containing","an","array","of","bools","for","each","bounding","box","per","image","indicating","if","the","bounding","box","is","certified","against","the","given","patch","."]
code: def certify(
      self,
      x: np.ndarray,
      patch_size: float = 0.01,
      offset: float = 0.1,
      batch_size: int = 128,
  ) -> List[np.ndarray]:
      """
      Checks if there is certifiable IoA robustness for each predicted bounding box.
  
      :param x: Sample input with shape as expected by the model.
      :param patch_size: The size of the patch to check against.
      :param offset: The offset to distinguish between the far and near patches.
      :return: A list containing an array of bools for each bounding box per image indicating if the bounding
               box is certified against the given patch.
      """
      if self.channels_first:
          _, height, width = self.input_shape
      else:
          height, width, _ = self.input_shape
  
      patch_size = np.sqrt(height * width * patch_size)
      height_offset = offset * height
      width_offset = offset * width
  
      # Get predictions
      predictions = self.predict(x, batch_size=batch_size)
  
      certifications: List[np.ndarray] = []
  
      for pred in tqdm(
          predictions, desc="ObjectSeeker", disable=not self.verbose
      ):
          boxes = pred["boxes"]
  
          # Far patch
          far_patch_map = np.ones(
              (len(boxes), height, width), dtype=bool
          )
          for i, box in enumerate(boxes):
              x_1 = int(max(0, box[1] - patch_size - height_offset))
              x_2 = int(min(box[3] + height_offset + 1, height))
              y_1 = int(max(0, box[0] - patch_size - width_offset))
              y_2 = int(min(box[2] + width_offset + 1, width))
              far_patch_map[i, x_1:x_2, y_1:y_2] = False
          far_vulnerable = np.any(far_patch_map, axis=(-2, -1))
  
          # Close patch
          close_patch_map = np.ones(
              (len(boxes), height, width), dtype=bool
          )
          for i, box in enumerate(boxes):
              x_1 = int(max(0, box[1] - patch_size))
              x_2 = int(min(box[3] + 1, height))
              y_1 = int(max(0, box[0] - patch_size))
              y_2 = int(min(box[2] + 1, width))
              close_patch_map[i, x_1:x_2, y_1:y_2] = False
          close_vulnerable = np.any(close_patch_map, axis=(-2, -1))
  
          # Over patch
          close_patch_map = np.ones(
              (len(boxes), height, width), dtype=bool
          )
          for i, box in enumerate(boxes):
              x_1 = int(max(0, box[1] - patch_size))
              x_2 = int(min(box[3] + 1, height))
              y_1 = int(max(0, box[0] - patch_size))
              y_2 = int(min(box[2] + 1, width))
              close_patch_map[i, x_1:x_2, y_1:y_2] = True
          over_vulnerable = np.any(close_patch_map, axis=(-2, -1))
  
          cert = np.logical_and.reduce(
              (far_vulnerable, close_vulnerable, over_vulnerable)
          )
          certifications.append(cert)
  
      return certifications
  
file_path: adversarial-robustness-toolbox/art/estimators/certification/object_seeker/object_seeker.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import abc
  import logging
  from typing import Dict, List, Tuple
  import numpy
  from sklearn.cluster import DBSCAN
  from tqdm.auto import tqdm
  from art.utils import intersection_over_area, non_maximum_suppression
label_desc: Use image node_id 9 for calling the ObjectSeekerMixin obj's underlying member method code with example usage: obj.certify(x, patch_size, offset, batch_size) and returns: certifications