docstr: Tests that bbox_targets is consistent with proposals_label.
  
  That means we test that we have the same number of elements in
  bbox_targets and proposals_label, and that only the proposals
  marked with a class are assigned a non-zero bbox_target.
docstr_tok: ["Tests","that","bbox_targets","is","consistent","with","proposals_label",".","That","means","we","test","that","we","have","the","same","number","of","elements","in","bbox_targets","and","proposals_label",",","and","that","only","the","proposals","marked","with","a","class","are","assigned","a","non-zero","bbox_target","."]
code: def testBboxTargetConsistency(self):
      """Tests that bbox_targets is consistent with proposals_label.
  
      That means we test that we have the same number of elements in
      bbox_targets and proposals_label, and that only the proposals
      marked with a class are assigned a non-zero bbox_target.
      """
  
      config = EasyDict(
          {
              "foreground_threshold": 0.5,
              "background_threshold_high": 0.5,
              "background_threshold_low": 0,  # use 0 to get complete batch
              "foreground_fraction": 0.5,
              # We change the minibatch_size the catch all our foregrounds
              "minibatch_size": 8,
          }
      )
  
      model = RCNNTarget(self._num_classes, config, seed=0)
  
      gt_boxes = tf.constant(
          [(200, 300, 250, 390, self._placeholder_label)],
          dtype=tf.float32,
      )
  
      proposed_boxes = tf.constant(
          [
              (12, 70, 350, 540),  # noise
              (190, 310, 240, 370),  # IoU: 0.4763
              (197, 300, 252, 389),  # IoU: 0.9015
              (196, 300, 252, 389),  # IoU: 0.8859
              (197, 303, 252, 394),  # IoU: 0.8459
              (180, 310, 235, 370),  # IoU: 0.3747
              (0, 0, 400, 400),  # noise
              (197, 302, 252, 389),  # IoU: 0.8832
              (0, 0, 400, 400),  # noise
          ],
          dtype=tf.float32,
      )
  
      (proposals_label, bbox_targets) = self._run_rcnn_target(
          model, gt_boxes, proposed_boxes
      )
  
      foreground_idxs = np.nonzero(proposals_label >= 1)
      non_empty_bbox_target_idxs = np.nonzero(
          np.any(bbox_targets, axis=1)
      )
  
      self.assertAllEqual(foreground_idxs, non_empty_bbox_target_idxs)
      self.assertGreater(
          proposals_label[proposals_label >= 1].shape[0], 0
      )
      self.assertEqual(
          proposals_label[proposals_label >= 0].shape[0],
          config.minibatch_size,
      )
  
file_path: luminoth/luminoth/models/fasterrcnn/rcnn_target_test.py
imports: import numpy
  import tensorflow
  from easydict import EasyDict
  from luminoth.models.fasterrcnn.rcnn_target import RCNNTarget
  from luminoth.utils.test.gt_boxes import generate_gt_boxes
label_desc: Use image node_id 8 for calling the RCNNTargetTest obj's underlying member method code with example usage: obj.testBboxTargetConsistency() without return types