class_docstr: Faster RCNN Network module
  
  Builds the Faster RCNN network architecture using different submodules.
  Calculates the total loss of the model based on the different losses by
  each of the submodules.
  
  It is also responsible for building the anchor reference which is used in
  graph for generating the dynamic anchors.
class_docstr_tok: ["Faster","RCNN","Network","module","Builds","the","Faster","RCNN","network","architecture","using","different","submodules",".","Calculates","the","total","loss","of","the","model","based","on","the","different","losses","by","each","of","the","submodules",".","It","is","also","responsible","for","building","the","anchor","reference","which","is","used","in","graph","for","generating","the","dynamic","anchors","."]
docstr: Returns bounding boxes and classification probabilities.
  
  Args:
      image: A tensor with the image.
          Its shape should be `(height, width, 3)`.
      gt_boxes: A tensor with all the ground truth boxes of that image.
          Its shape should be `(num_gt_boxes, 5)`
          Where for each gt box we have (x1, y1, x2, y2, label),
          in that order.
      is_training: A boolean to whether or not it is used for training.
  
  Returns:
      classification_prob: A tensor with the softmax probability for
          each of the bounding boxes found in the image.
          Its shape should be: (num_bboxes, num_categories + 1)
      classification_bbox: A tensor with the bounding boxes found.
          It's shape should be: (num_bboxes, 4). For each of the bboxes
          we have (x1, y1, x2, y2)
docstr_tok: ["Returns","bounding","boxes","and","classification","probabilities",".","Args",":","image",":","A","tensor","with","the","image",".","Its","shape","should","be","`","(","height",",","width",",","3",")","`",".","gt_boxes",":","A","tensor","with","all","the","ground","truth","boxes","of","that","image",".","Its","shape","should","be","`","(","num_gt_boxes",",","5",")","`","Where","for","each","gt","box","we","have","(","x1",",","y1",",","x2",",","y2",",","label",")",",","in","that","order",".","is_training",":","A","boolean","to","whether","or","not","it","is","used","for","training",".","Returns",":","classification_prob",":","A","tensor","with","the","softmax","probability","for","each","of","the","bounding","boxes","found","in","the","image",".","Its","shape","should","be",":","(","num_bboxes",",","num_categories","+","1",")","classification_bbox",":","A","tensor","with","the","bounding","boxes","found",".","It","'s","shape","should","be",":","(","num_bboxes",",","4",")",".","For","each","of","the","bboxes","we","have","(","x1",",","y1",",","x2",",","y2",")"]
code: def _build(self, image, gt_boxes=None, is_training=False):
      """
      Returns bounding boxes and classification probabilities.
  
      Args:
          image: A tensor with the image.
              Its shape should be `(height, width, 3)`.
          gt_boxes: A tensor with all the ground truth boxes of that image.
              Its shape should be `(num_gt_boxes, 5)`
              Where for each gt box we have (x1, y1, x2, y2, label),
              in that order.
          is_training: A boolean to whether or not it is used for training.
  
      Returns:
          classification_prob: A tensor with the softmax probability for
              each of the bounding boxes found in the image.
              Its shape should be: (num_bboxes, num_categories + 1)
          classification_bbox: A tensor with the bounding boxes found.
              It's shape should be: (num_bboxes, 4). For each of the bboxes
              we have (x1, y1, x2, y2)
      """
      if gt_boxes is not None:
          gt_boxes = tf.cast(gt_boxes, tf.float32)
      # A Tensor with the feature map for the image,
      # its shape should be `(feature_height, feature_width, 512)`.
      # The shape depends of the pretrained network in use.
  
      # Set rank and last dimension before using base network
      # TODO: Why does it loose information when using queue?
      image.set_shape((None, None, 3))
  
      conv_feature_map = self.base_network(
          tf.expand_dims(image, 0), is_training=is_training
      )
  
      # The RPN submodule which generates proposals of objects.
      self._rpn = RPN(
          self._num_anchors,
          self._config.model.rpn,
          debug=self._debug,
          seed=self._seed,
      )
      if self._with_rcnn:
          # The RCNN submodule which classifies RPN's proposals and
          # classifies them as background or a specific class.
          self._rcnn = RCNN(
              self._num_classes,
              self._config.model.rcnn,
              debug=self._debug,
              seed=self._seed,
          )
  
      image_shape = tf.shape(image)[0:2]
  
      variable_summaries(
          conv_feature_map, "conv_feature_map", "reduced"
      )
  
      # Generate anchors for the image based on the anchor reference.
      all_anchors = self._generate_anchors(tf.shape(conv_feature_map))
      rpn_prediction = self._rpn(
          conv_feature_map,
          image_shape,
          all_anchors,
          gt_boxes=gt_boxes,
          is_training=is_training,
      )
  
      prediction_dict = {
          "rpn_prediction": rpn_prediction,
      }
  
      if self._debug:
          prediction_dict["image"] = image
          prediction_dict["image_shape"] = image_shape
          prediction_dict["all_anchors"] = all_anchors
          prediction_dict["anchor_reference"] = tf.convert_to_tensor(
              self._anchor_reference
          )
          if gt_boxes is not None:
              prediction_dict["gt_boxes"] = gt_boxes
          prediction_dict["conv_feature_map"] = conv_feature_map
  
      if self._with_rcnn:
          proposals = tf.stop_gradient(rpn_prediction["proposals"])
          classification_pred = self._rcnn(
              conv_feature_map,
              proposals,
              image_shape,
              self.base_network,
              gt_boxes=gt_boxes,
              is_training=is_training,
          )
  
          prediction_dict[
              "classification_prediction"
          ] = classification_pred
  
      return prediction_dict
  
file_path: luminoth/luminoth/models/fasterrcnn/fasterrcnn.py
imports: import numpy
  import sonnet
  import tensorflow
  from luminoth.models.fasterrcnn.rcnn import RCNN
  from luminoth.models.fasterrcnn.rpn import RPN
  from luminoth.models.base import TruncatedBaseNetwork
  from luminoth.utils.anchors import generate_anchors_reference
  from luminoth.utils.vars import VAR_LOG_LEVELS, variable_summaries
label_desc: Use image node_id 2 for calling the FasterRCNN obj's underlying member method code with example usage: obj._build(image, gt_boxes, is_training) and returns: prediction_dict