コード例 #1
0
 def test_boolean_mask(self):
     corners = tf.constant(
         [4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]])
     indicator = tf.constant([True, False, True, False, True], tf.bool)
     expected_subset = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
     boxes = box_list.BoxList(corners)
     subset = box_list_ops.boolean_mask(boxes, indicator)
     with self.test_session() as sess:
         subset_output = sess.run(subset.get())
         self.assertAllClose(subset_output, expected_subset)
コード例 #2
0
    def test_boolean_mask_with_field(self):
        corners = tf.constant(
            [4 * [0.0], 4 * [1.0], 4 * [2.0], 4 * [3.0], 4 * [4.0]])
        indicator = tf.constant([True, False, True, False, True], tf.bool)
        weights = tf.constant([[.1], [.3], [.5], [.7], [.9]], tf.float32)
        expected_subset = [4 * [0.0], 4 * [2.0], 4 * [4.0]]
        expected_weights = [[.1], [.5], [.9]]

        boxes = box_list.BoxList(corners)
        boxes.add_field('weights', weights)
        subset = box_list_ops.boolean_mask(boxes, indicator, ['weights'])
        with self.test_session() as sess:
            subset_output, weights_output = sess.run(
                [subset.get(), subset.get_field('weights')])
            self.assertAllClose(subset_output, expected_subset)
            self.assertAllClose(weights_output, expected_weights)
コード例 #3
0
ファイル: crnn.py プロジェクト: AXATechLab/models
            def compute_loss():
                sampled_boxlist = box_list_ops.boolean_mask(
                    detection_boxlist, sampled_indices)

                sampled_padded_boxlist = box_list_ops.pad_or_clip_box_list(
                    sampled_boxlist, num_boxes=self.batch_size)
                detection_boxes = sampled_padded_boxlist.get()
                detection_transcriptions = sampled_padded_boxlist.get_field(
                    fields.BoxListFields.transcription)
                # detection_transcriptions = tf.Print(detection_transcriptions, [detection_transcriptions], message="These are the subsampled GTs transcr.", summarize=99999)
                detection_scores = sampled_padded_boxlist.get_field(
                    fields.BoxListFields.scores)
                num_detections = tf.minimum(sampled_boxlist.num_boxes(),
                                            self.batch_size)
                transcriptions_dict, eval_metric_ops = self._predict_lstm(
                    rpn_features_to_crop, detection_boxes,
                    detection_transcriptions, detection_scores, num_detections)
                return [
                    self.loss(transcriptions_dict),
                    (transcriptions_dict, eval_metric_ops)
                ]