class_docstr: This class implements a model-specific object detector using Faster-RCNN and TensorFlow.
class_docstr_tok: ["This","class","implements","a","model-specific","object","detector","using","Faster-RCNN","and","TensorFlow","."]
docstr: Perform prediction for a batch of inputs.
  
  :param x: Samples of shape (nb_samples, height, width, nb_channels).
  :param batch_size: Batch size.
  :param standardise_output: True if output should be standardised to PyTorch format. Box coordinates will be
                             scaled from [0, 1] to image dimensions, label index will be increased by 1 to adhere
                             to COCO categories and the boxes will be changed to [x1, y1, x2, y2] format, with
                             0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
  
  :return: Predictions of format `List[Dict[str, np.ndarray]]`, one for each input image. The
           fields of the Dict are as follows:
  
           - boxes [N, 4]: the boxes in [y1, x1, y2, x2] format, with 0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
                           Can be changed to PyTorch format with `standardise_output=True`.
           - labels [N]: the labels for each image in TensorFlow format. Can be changed to PyTorch format with
                         `standardise_output=True`.
           - scores [N]: the scores or each prediction.
docstr_tok: ["Perform","prediction","for","a","batch","of","inputs",".",":","param","x",":","Samples","of","shape","(","nb_samples",",","height",",","width",",","nb_channels",")",".",":","param","batch_size",":","Batch","size",".",":","param","standardise_output",":","True","if","output","should","be","standardised","to","PyTorch","format",".","Box","coordinates","will","be","scaled","from","[","0",",","1","]","to","image","dimensions",",","label","index","will","be","increased","by","1","to","adhere","to","COCO","categories","and","the","boxes","will","be","changed","to","[","x1",",","y1",",","x2",",","y2","]","format",",","with","0","<","=","x1","<","x2","<","=","W","and","0","<","=","y1","<","y2","<","=","H.",":","return",":","Predictions","of","format","`","List","[","Dict","[","str",",","np.ndarray","]","]","`",",","one","for","each","input","image",".","The","fields","of","the","Dict","are","as","follows",":","-","boxes","[","N",",","4","]",":","the","boxes","in","[","y1",",","x1",",","y2",",","x2","]","format",",","with","0","<","=","x1","<","x2","<","=","W","and","0","<","=","y1","<","y2","<","=","H.","Can","be","changed","to","PyTorch","format","with","`","standardise_output=True","`",".","-","labels","[","N","]",":","the","labels","for","each","image","in","TensorFlow","format",".","Can","be","changed","to","PyTorch","format","with","`","standardise_output=True","`",".","-","scores","[","N","]",":","the","scores","or","each","prediction","."]
code: def predict(  # pylint: disable=W0221
      self,
      x: np.ndarray,
      batch_size: int = 128,
      standardise_output: bool = False,
      **kwargs,
  ) -> List[Dict[str, np.ndarray]]:
      """
      Perform prediction for a batch of inputs.
  
      :param x: Samples of shape (nb_samples, height, width, nb_channels).
      :param batch_size: Batch size.
      :param standardise_output: True if output should be standardised to PyTorch format. Box coordinates will be
                                 scaled from [0, 1] to image dimensions, label index will be increased by 1 to adhere
                                 to COCO categories and the boxes will be changed to [x1, y1, x2, y2] format, with
                                 0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
  
      :return: Predictions of format `List[Dict[str, np.ndarray]]`, one for each input image. The
               fields of the Dict are as follows:
  
               - boxes [N, 4]: the boxes in [y1, x1, y2, x2] format, with 0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
                               Can be changed to PyTorch format with `standardise_output=True`.
               - labels [N]: the labels for each image in TensorFlow format. Can be changed to PyTorch format with
                             `standardise_output=True`.
               - scores [N]: the scores or each prediction.
      """
      # Only do prediction if is_training is False
      if self.is_training:
          raise NotImplementedError(
              "This object detector was loaded in training mode and therefore not support prediction."
          )
  
      # Apply preprocessing
      x, _ = self._apply_preprocessing(x, y=None, fit=False)
  
      # Check if batch processing is appropriately set
      if (
          self.images is not None
          and self.images.shape[0].value is not None
      ):
          if (
              x.shape[0] % self.images.shape[0].value != 0
          ):  # pragma: no cover
              raise ValueError(
                  "Number of prediction samples must be a multiple of input size."
              )
  
          logger.warning("Reset batch size to input size.")
          batch_size = self.images.shape[0].value
  
      # Run prediction with batch processing
      num_samples = x.shape[0]
      num_batch = int(np.ceil(num_samples / float(batch_size)))
      results = []
  
      for m in range(num_batch):
          # Batch indexes
          begin, end = m * batch_size, min(
              (m + 1) * batch_size, num_samples
          )
  
          # Create feed_dict
          feed_dict = {self.images: x[begin:end]}
  
          # Run prediction
          batch_results = self._sess.run(
              self._detections, feed_dict=feed_dict
          )
  
          for i in range(end - begin):
              d_sample = {}
  
              d_sample["boxes"] = batch_results["detection_boxes"][i]
              d_sample["labels"] = batch_results["detection_classes"][
                  i
              ].astype(int)
  
              if standardise_output:
                  from art.estimators.object_detection.utils import (
                      convert_tf_to_pt,
                  )
  
                  d_sample = convert_tf_to_pt(
                      y=[d_sample], height=x.shape[1], width=x.shape[2]
                  )[0]
  
              d_sample["scores"] = batch_results["detection_scores"][i]
  
              results.append(d_sample)
  
      return results
  
imports: import logging
  from typing import List, Dict, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from art.estimators.object_detection.object_detector import ObjectDetectorMixin
  from art.estimators.tensorflow import TensorFlowEstimator
  from art.utils import get_file
  from art import config
label_desc: Use image node_id 6 for calling the TensorFlowFasterRCNN obj's underlying member method code with example usage: obj.predict(x, batch_size, standardise_output) and returns: results