Python object_detection.protos.post_processing_pb2.PostProcessing() Examples
The following are 30
code examples of object_detection.protos.post_processing_pb2.PostProcessing().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
object_detection.protos.post_processing_pb2
, or try the search function
.
Example #1
Source File: post_processing_builder_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #2
Source File: post_processing_builder.py From Hands-On-Machine-Learning-with-OpenCV-4 with MIT License | 6 votes |
def _build_score_converter(score_converter_config): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return tf.identity if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return tf.sigmoid if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return tf.nn.softmax raise ValueError('Unknown score converter.')
Example #3
Source File: post_processing_builder_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_build_identity_score_converter_with_logit_scale(self): post_processing_text_proto = """ score_converter: IDENTITY logit_scale: 2.0 """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) _, score_converter = post_processing_builder.build(post_processing_config) self.assertEqual(score_converter.__name__, 'identity_with_logit_scale') inputs = tf.constant([1, 1], tf.float32) outputs = score_converter(inputs) with self.test_session() as sess: converted_scores = sess.run(outputs) expected_converted_scores = sess.run(tf.constant([.5, .5], tf.float32)) self.assertAllClose(converted_scores, expected_converted_scores)
Example #4
Source File: post_processing_builder.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def _build_score_converter(score_converter_config): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return tf.identity if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return tf.sigmoid if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return tf.nn.softmax raise ValueError('Unknown score converter.')
Example #5
Source File: post_processing_builder.py From object_detector_app with MIT License | 6 votes |
def _build_score_converter(score_converter_config): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return tf.identity if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return tf.sigmoid if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return tf.nn.softmax raise ValueError('Unknown score converter.')
Example #6
Source File: post_processing_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_identity_score_converter_with_logit_scale(self): post_processing_text_proto = """ score_converter: IDENTITY logit_scale: 2.0 """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) _, score_converter = post_processing_builder.build(post_processing_config) self.assertEqual(score_converter.__name__, 'identity_with_logit_scale') inputs = tf.constant([1, 1], tf.float32) outputs = score_converter(inputs) with self.test_session() as sess: converted_scores = sess.run(outputs) expected_converted_scores = sess.run(tf.constant([.5, .5], tf.float32)) self.assertAllClose(converted_scores, expected_converted_scores)
Example #7
Source File: post_processing_builder_test.py From object_detector_app with MIT License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #8
Source File: post_processing_builder_test.py From Gun-Detector with Apache License 2.0 | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #9
Source File: post_processing_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #10
Source File: post_processing_builder.py From DOTA_models with Apache License 2.0 | 6 votes |
def _build_score_converter(score_converter_config): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return tf.identity if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return tf.sigmoid if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return tf.nn.softmax raise ValueError('Unknown score converter.')
Example #11
Source File: post_processing_builder_test.py From tensorflow with BSD 2-Clause "Simplified" License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #12
Source File: post_processing_builder.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def _build_score_converter(score_converter_config, logit_scale): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. logit_scale: temperature to use for SOFTMAX score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return _score_converter_fn_with_logit_scale(tf.identity, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return _score_converter_fn_with_logit_scale(tf.sigmoid, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return _score_converter_fn_with_logit_scale(tf.nn.softmax, logit_scale) raise ValueError('Unknown score converter.')
Example #13
Source File: post_processing_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #14
Source File: post_processing_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_identity_score_converter_with_logit_scale(self): post_processing_text_proto = """ score_converter: IDENTITY logit_scale: 2.0 """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) _, score_converter = post_processing_builder.build(post_processing_config) self.assertEqual(score_converter.__name__, 'identity_with_logit_scale') inputs = tf.constant([1, 1], tf.float32) outputs = score_converter(inputs) with self.test_session() as sess: converted_scores = sess.run(outputs) expected_converted_scores = sess.run(tf.constant([.5, .5], tf.float32)) self.assertAllClose(converted_scores, expected_converted_scores)
Example #15
Source File: post_processing_builder.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def _build_score_converter(score_converter_config, logit_scale): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. logit_scale: temperature to use for SOFTMAX score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return _score_converter_fn_with_logit_scale(tf.identity, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return _score_converter_fn_with_logit_scale(tf.sigmoid, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return _score_converter_fn_with_logit_scale(tf.nn.softmax, logit_scale) raise ValueError('Unknown score converter.')
Example #16
Source File: post_processing_builder.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def _build_score_converter(score_converter_config, logit_scale): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. logit_scale: temperature to use for SOFTMAX score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return _score_converter_fn_with_logit_scale(tf.identity, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return _score_converter_fn_with_logit_scale(tf.sigmoid, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return _score_converter_fn_with_logit_scale(tf.nn.softmax, logit_scale) raise ValueError('Unknown score converter.')
Example #17
Source File: post_processing_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #18
Source File: post_processing_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_build_identity_score_converter_with_logit_scale(self): post_processing_text_proto = """ score_converter: IDENTITY logit_scale: 2.0 """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) _, score_converter = post_processing_builder.build(post_processing_config) self.assertEqual(score_converter.__name__, 'identity_with_logit_scale') inputs = tf.constant([1, 1], tf.float32) outputs = score_converter(inputs) with self.test_session() as sess: converted_scores = sess.run(outputs) expected_converted_scores = sess.run(tf.constant([.5, .5], tf.float32)) self.assertAllClose(converted_scores, expected_converted_scores)
Example #19
Source File: post_processing_builder_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_build_identity_score_converter_with_logit_scale(self): post_processing_text_proto = """ score_converter: IDENTITY logit_scale: 2.0 """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) _, score_converter = post_processing_builder.build(post_processing_config) self.assertEqual(score_converter.__name__, 'identity_with_logit_scale') inputs = tf.constant([1, 1], tf.float32) outputs = score_converter(inputs) with self.test_session() as sess: converted_scores = sess.run(outputs) expected_converted_scores = sess.run(tf.constant([.5, .5], tf.float32)) self.assertAllClose(converted_scores, expected_converted_scores)
Example #20
Source File: post_processing_builder.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def _build_score_converter(score_converter_config, logit_scale): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. logit_scale: temperature to use for SOFTMAX score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return _score_converter_fn_with_logit_scale(tf.identity, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return _score_converter_fn_with_logit_scale(tf.sigmoid, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return _score_converter_fn_with_logit_scale(tf.nn.softmax, logit_scale) raise ValueError('Unknown score converter.')
Example #21
Source File: post_processing_builder_test.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #22
Source File: post_processing_builder_test.py From Traffic-Rule-Violation-Detection-System with MIT License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #23
Source File: post_processing_builder.py From yolo_v2 with Apache License 2.0 | 6 votes |
def _build_score_converter(score_converter_config, logit_scale): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. logit_scale: temperature to use for SOFTMAX score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return _score_converter_fn_with_logit_scale(tf.identity, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return _score_converter_fn_with_logit_scale(tf.sigmoid, logit_scale) if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return _score_converter_fn_with_logit_scale(tf.nn.softmax, logit_scale) raise ValueError('Unknown score converter.')
Example #24
Source File: post_processing_builder_test.py From DOTA_models with Apache License 2.0 | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #25
Source File: post_processing_builder.py From garbage-object-detection-tensorflow with MIT License | 6 votes |
def _build_score_converter(score_converter_config): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return tf.identity if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return tf.sigmoid if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return tf.nn.softmax raise ValueError('Unknown score converter.')
Example #26
Source File: post_processing_builder_test.py From HereIsWally with MIT License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #27
Source File: post_processing_builder_test.py From yolo_v2 with Apache License 2.0 | 6 votes |
def test_build_identity_score_converter_with_logit_scale(self): post_processing_text_proto = """ score_converter: IDENTITY logit_scale: 2.0 """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) _, score_converter = post_processing_builder.build(post_processing_config) self.assertEqual(score_converter.__name__, 'identity_with_logit_scale') inputs = tf.constant([1, 1], tf.float32) outputs = score_converter(inputs) with self.test_session() as sess: converted_scores = sess.run(outputs) expected_converted_scores = sess.run(tf.constant([.5, .5], tf.float32)) self.assertAllClose(converted_scores, expected_converted_scores)
Example #28
Source File: post_processing_builder.py From HereIsWally with MIT License | 6 votes |
def _build_score_converter(score_converter_config): """Builds score converter based on the config. Builds one of [tf.identity, tf.sigmoid, tf.softmax] score converters based on the config. Args: score_converter_config: post_processing_pb2.PostProcessing.score_converter. Returns: Callable score converter op. Raises: ValueError: On unknown score converter. """ if score_converter_config == post_processing_pb2.PostProcessing.IDENTITY: return tf.identity if score_converter_config == post_processing_pb2.PostProcessing.SIGMOID: return tf.sigmoid if score_converter_config == post_processing_pb2.PostProcessing.SOFTMAX: return tf.nn.softmax raise ValueError('Unknown score converter.')
Example #29
Source File: post_processing_builder_test.py From Hands-On-Machine-Learning-with-OpenCV-4 with MIT License | 6 votes |
def test_build_non_max_suppressor_with_correct_parameters(self): post_processing_text_proto = """ batch_non_max_suppression { score_threshold: 0.7 iou_threshold: 0.6 max_detections_per_class: 100 max_total_detections: 300 } """ post_processing_config = post_processing_pb2.PostProcessing() text_format.Merge(post_processing_text_proto, post_processing_config) non_max_suppressor, _ = post_processing_builder.build( post_processing_config) self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100) self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300) self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7) self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6)
Example #30
Source File: post_processing_builder.py From tensorflow with BSD 2-Clause "Simplified" License | 5 votes |
def build(post_processing_config): """Builds callables for post-processing operations. Builds callables for non-max suppression and score conversion based on the configuration. Non-max suppression callable takes `boxes`, `scores`, and optionally `clip_window`, `parallel_iterations` and `scope` as inputs. It returns `nms_boxes`, `nms_scores`, `nms_nms_classes` and `num_detections`. See post_processing.batch_multiclass_non_max_suppression for the type and shape of these tensors. Score converter callable should be called with `input` tensor. The callable returns the output from one of 3 tf operations based on the configuration - tf.identity, tf.sigmoid or tf.nn.softmax. See tensorflow documentation for argument and return value descriptions. Args: post_processing_config: post_processing.proto object containing the parameters for the post-processing operations. Returns: non_max_suppressor_fn: Callable for non-max suppression. score_converter_fn: Callable for score conversion. Raises: ValueError: if the post_processing_config is of incorrect type. """ if not isinstance(post_processing_config, post_processing_pb2.PostProcessing): raise ValueError('post_processing_config not of type ' 'post_processing_pb2.Postprocessing.') non_max_suppressor_fn = _build_non_max_suppressor( post_processing_config.batch_non_max_suppression) score_converter_fn = _build_score_converter( post_processing_config.score_converter) return non_max_suppressor_fn, score_converter_fn