docstr: Tests we never get zero foregrounds.
  
  We're doing iterations with random gt_boxes and proposals under
  conditions that make it likely we would get zero foregrounds if there
  is a bug in the code. (Very few gt_boxes and a small minibatch_size).
docstr_tok: ["Tests","we","never","get","zero","foregrounds",".","We","'re","doing","iterations","with","random","gt_boxes","and","proposals","under","conditions","that","make","it","likely","we","would","get","zero","foregrounds","if","there","is","a","bug","in","the","code",".","(","Very","few","gt_boxes","and","a","small","minibatch_size",")","."]
code: def testNonZeroForegrounds(self):
      """Tests we never get zero foregrounds.
  
      We're doing iterations with random gt_boxes and proposals under
      conditions that make it likely we would get zero foregrounds if there
      is a bug in the code. (Very few gt_boxes and a small minibatch_size).
      """
      number_of_iterations = 50
      for _ in range(number_of_iterations):
          im_shape = np.random.randint(
              low=600, high=980, size=2, dtype=np.int32
          )
          total_boxes = np.random.randint(low=1, high=4, dtype=np.int32)
          total_proposals = np.random.randint(
              low=4, high=8, dtype=np.int32
          )
          # Generate gt_boxes and then add a label.
          gt_boxes = generate_gt_boxes(total_boxes, im_shape)
          gt_boxes_w_label = np.concatenate(
              [gt_boxes, [[self._placeholder_label]] * total_boxes],
              axis=1,
          ).astype(np.float32)
          # Generate the proposals and add the batch number.
          proposed_boxes = generate_gt_boxes(total_proposals, im_shape)
          # Run RCNNTarget.
          (proposals_label, _) = self._run_rcnn_target(
              self._shared_model,
              gt_boxes_w_label,
              proposed_boxes.astype(np.float32),
          )
          # Assertion
          foreground_number = proposals_label[
              proposals_label > 0
          ].shape[0]
          self.assertGreater(foreground_number, 0)
  
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 10 for calling the RCNNTargetTest obj's underlying member method code with example usage: obj.testNonZeroForegrounds() without return types