class_docstr: Encapsulates an object detection model behavior.
  
  In order to perform object detection with a model implemented within
  Luminoth, this class should be used.
  
  Attributes:
      classes (list of str): Ordered class names for the detector.
      prob (float): Default probability threshold for predictions.
  
  TODO:
      - Don't create a TF session internally (or make its creation optional)
        in order to be compatible with both TF-Eager and Jupyter Notebooks.
      - Manage multiple instantiations correctly in order to avoid creating
        the same TF objects over and over (which appends the `_N` suffix to
        the graph and makes the checkpoint loading fail).
class_docstr_tok: ["Encapsulates","an","object","detection","model","behavior",".","In","order","to","perform","object","detection","with","a","model","implemented","within","Luminoth",",","this","class","should","be","used",".","Attributes",":","classes","(","list","of","str",")",":","Ordered","class","names","for","the","detector",".","prob","(","float",")",":","Default","probability","threshold","for","predictions",".","TODO",":","-","Do","n't","create","a","TF","session","internally","(","or","make","its","creation","optional",")","in","order","to","be","compatible","with","both","TF-Eager","and","Jupyter","Notebooks",".","-","Manage","multiple","instantiations","correctly","in","order","to","avoid","creating","the","same","TF","objects","over","and","over","(","which","appends","the","`","_N","`","suffix","to","the","graph","and","makes","the","checkpoint","loading","fail",")","."]
docstr: Run the detector through a set of images.
  
  Arguments:
      images (numpy.ndarray or list): Either array of dimensions
          `(height, width, channels)` (single image) or array of
          dimensions `(number_of_images, height, width, channels)`
          (multiple images). If a list, must be a list of rank 3 arrays.
      prob (float): Override configured probability threshold for
          predictions.
      classes (set of str): Override configured class names to consider.
  
  Returns:
      Either list of objects detected in the image (single image case) or
      list of list of objects detected (multiple images case).
  
      In the multiple images case, the outer list has `number_of_images`
      elements, while the inner ones have the number of objects detected
      in each image.
  
      Each object has the format::
  
          {
              'bbox': [x_min, y_min, x_max, y_max],
              'label': '<cat|dog|person|...>' | 0..C,
              'prob': prob
          }
  
      The coordinates are integers, where `(x_min, y_min)` are the
      coordinates of the top-left corner of the bounding box, while
      `(x_max, y_max)` the bottom-right. By convention, the top-left
      corner of the image is coordinate `(0, 0)`.
  
      The probability, `prob`, is a float between 0 and 1, indicating the
      confidence of the detection being correct.
  
      The label of the object, `label`, may be either a string if the
      classes file for the model is found or an integer between 0 and the
      number of classes `C`.
docstr_tok: ["Run","the","detector","through","a","set","of","images",".","Arguments",":","images","(","numpy.ndarray","or","list",")",":","Either","array","of","dimensions","`","(","height",",","width",",","channels",")","`","(","single","image",")","or","array","of","dimensions","`","(","number_of_images",",","height",",","width",",","channels",")","`","(","multiple","images",")",".","If","a","list",",","must","be","a","list","of","rank","3","arrays",".","prob","(","float",")",":","Override","configured","probability","threshold","for","predictions",".","classes","(","set","of","str",")",":","Override","configured","class","names","to","consider",".","Returns",":","Either","list","of","objects","detected","in","the","image","(","single","image","case",")","or","list","of","list","of","objects","detected","(","multiple","images","case",")",".","In","the","multiple","images","case",",","the","outer","list","has","`","number_of_images","`","elements",",","while","the","inner","ones","have","the","number","of","objects","detected","in","each","image",".","Each","object","has","the","format",":",":","{","'bbox","'",":","[","x_min",",","y_min",",","x_max",",","y_max","]",",","'label","'",":","'","<","cat|dog|person|","...",">","'","|","0","..","C",",","'prob","'",":","prob","}","The","coordinates","are","integers",",","where","`","(","x_min",",","y_min",")","`","are","the","coordinates","of","the","top-left","corner","of","the","bounding","box",",","while","`","(","x_max",",","y_max",")","`","the","bottom-right",".","By","convention",",","the","top-left","corner","of","the","image","is","coordinate","`","(","0",",","0",")","`",".","The","probability",",","`","prob","`",",","is","a","float","between","0","and","1",",","indicating","the","confidence","of","the","detection","being","correct",".","The","label","of","the","object",",","`","label","`",",","may","be","either","a","string","if","the","classes","file","for","the","model","is","found","or","an","integer","between","0","and","the","number","of","classes","`","C","`","."]
code: def predict(self, images, prob=None, classes=None):
      """Run the detector through a set of images.
  
      Arguments:
          images (numpy.ndarray or list): Either array of dimensions
              `(height, width, channels)` (single image) or array of
              dimensions `(number_of_images, height, width, channels)`
              (multiple images). If a list, must be a list of rank 3 arrays.
          prob (float): Override configured probability threshold for
              predictions.
          classes (set of str): Override configured class names to consider.
  
      Returns:
          Either list of objects detected in the image (single image case) or
          list of list of objects detected (multiple images case).
  
          In the multiple images case, the outer list has `number_of_images`
          elements, while the inner ones have the number of objects detected
          in each image.
  
          Each object has the format::
  
              {
                  'bbox': [x_min, y_min, x_max, y_max],
                  'label': '<cat|dog|person|...>' | 0..C,
                  'prob': prob
              }
  
          The coordinates are integers, where `(x_min, y_min)` are the
          coordinates of the top-left corner of the bounding box, while
          `(x_max, y_max)` the bottom-right. By convention, the top-left
          corner of the image is coordinate `(0, 0)`.
  
          The probability, `prob`, is a float between 0 and 1, indicating the
          confidence of the detection being correct.
  
          The label of the object, `label`, may be either a string if the
          classes file for the model is found or an integer between 0 and the
          number of classes `C`.
  
      """
      # If it's a single image (ndarray of rank 3), turn into a list.
      single_image = False
      if not isinstance(images, list):
          if len(images.shape) == 3:
              images = [images]
              single_image = True
  
      if prob is None:
          prob = self.prob
  
      if classes is None:
          classes = self.classes
      else:
          classes = set(classes)
  
      # TODO: Remove the loop once (and if) we implement batch sizes. Neither
      # Faster R-CNN nor SSD support batch size yet, so it's the same for
      # now.
      predictions = []
      for image in images:
          predictions.append(
              [
                  pred
                  for pred in self._network.predict_image(image)
                  if pred["prob"] >= prob and pred["label"] in classes
              ]
          )
  
      if single_image:
          predictions = predictions[0]
  
      return predictions
  
imports: from luminoth.tools.checkpoint import get_checkpoint_config
  from luminoth.utils.predicting import PredictorNetwork
label_desc: Use image node_id 2 for calling the Detector obj's underlying member method code with example usage: obj.predict(images, prob, classes) and returns: predictions