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 masked copies of the image for each of lines following the ObjectSeeker algorithm. Then creates
  predictions on the base unmasked image and each of the masked image.
  
  :param x_i: A single image of shape CHW or HWC.
  :batch_size: Batch size.
  :return: Predictions for the base unmasked image and merged predictions for the masked image.
docstr_tok: ["Create","masked","copies","of","the","image","for","each","of","lines","following","the","ObjectSeeker","algorithm",".","Then","creates","predictions","on","the","base","unmasked","image","and","each","of","the","masked","image",".",":","param","x_i",":","A","single","image","of","shape","CHW","or","HWC",".",":","batch_size",":","Batch","size",".",":","return",":","Predictions","for","the","base","unmasked","image","and","merged","predictions","for","the","masked","image","."]
code: def _masked_predictions(
      self, x_i: np.ndarray, batch_size: int = 128, **kwargs
  ) -> Tuple[Dict[str, np.ndarray], Dict[str, np.ndarray]]:
      """
      Create masked copies of the image for each of lines following the ObjectSeeker algorithm. Then creates
      predictions on the base unmasked image and each of the masked image.
  
      :param x_i: A single image of shape CHW or HWC.
      :batch_size: Batch size.
      :return: Predictions for the base unmasked image and merged predictions for the masked image.
      """
      x_mask = np.repeat(
          x_i[np.newaxis], self.num_lines * 4 + 1, axis=0
      )
  
      if self.channels_first:
          height = self.input_shape[1]
          width = self.input_shape[2]
      else:
          height = self.input_shape[0]
          width = self.input_shape[1]
          x_mask = np.transpose(x_mask, (0, 3, 1, 2))
  
      idx = 1
  
      # Left masks
      for k in range(1, self.num_lines + 1):
          boundary = int(width / (self.num_lines + 1) * k)
          x_mask[idx, :, :, :boundary] = 0
          idx += 1
  
      # Right masks
      for k in range(1, self.num_lines + 1):
          boundary = width - int(width / (self.num_lines + 1) * k)
          x_mask[idx, :, :, boundary:] = 0
          idx += 1
  
      # Top masks
      for k in range(1, self.num_lines + 1):
          boundary = int(height / (self.num_lines + 1) * k)
          x_mask[idx, :, :boundary, :] = 0
          idx += 1
  
      # Bottom masks
      for k in range(1, self.num_lines + 1):
          boundary = height - int(height / (self.num_lines + 1) * k)
          x_mask[idx, :, boundary:, :] = 0
          idx += 1
  
      if not self.channels_first:
          x_mask = np.transpose(x_mask, (0, 2, 3, 1))
  
      predictions = self._predict_classifier(
          x=x_mask, batch_size=batch_size, **kwargs
      )
      filtered_predictions = [
          non_maximum_suppression(
              pred,
              iou_threshold=self.iou_threshold,
              confidence_threshold=self.confidence_threshold,
          )
          for pred in predictions
      ]
  
      # Extract base predictions
      base_predictions = filtered_predictions[0]
  
      # Extract and merge masked predictions
      boxes = np.concatenate(
          [pred["boxes"] for pred in filtered_predictions[1:]]
      )
      labels = np.concatenate(
          [pred["labels"] for pred in filtered_predictions[1:]]
      )
      scores = np.concatenate(
          [pred["scores"] for pred in filtered_predictions[1:]]
      )
      merged_predictions = {
          "boxes": boxes,
          "labels": labels,
          "scores": scores,
      }
      masked_predictions = non_maximum_suppression(
          merged_predictions,
          iou_threshold=self.iou_threshold,
          confidence_threshold=self.confidence_threshold,
      )
  
      return base_predictions, masked_predictions
  
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 6 for calling the ObjectSeekerMixin obj's underlying member method code with example usage: obj._masked_predictions(x_i, batch_size) and returns: base_predictions,  masked_predictions