Python object_detection.protos.losses_pb2.Loss() Examples
The following are 30
code examples of object_detection.protos.losses_pb2.Loss().
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.losses_pb2
, or try the search function
.
Example #1
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_weighted_softmax_classification_loss(self): losses_text_proto = """ classification_loss { weighted_softmax { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSoftmaxClassificationLoss))
Example #2
Source File: losses_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_build_weighted_l2_localization_loss(self): losses_text_proto = """ localization_loss { weighted_l2 { } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedL2LocalizationLoss))
Example #3
Source File: losses_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_build_weighted_smooth_l1_localization_loss_non_default_delta(self): losses_text_proto = """ localization_loss { weighted_smooth_l1 { delta: 0.1 } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedSmoothL1LocalizationLoss)) self.assertAlmostEqual(localization_loss._delta, 0.1)
Example #4
Source File: losses_builder_test.py From Person-Detection-and-Tracking with MIT License | 6 votes |
def test_build_weighted_iou_localization_loss(self): losses_text_proto = """ localization_loss { weighted_iou { } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedIOULocalizationLoss))
Example #5
Source File: losses_builder_test.py From DOTA_models with Apache License 2.0 | 6 votes |
def test_build_weighted_softmax_classification_loss(self): losses_text_proto = """ classification_loss { weighted_softmax { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSoftmaxClassificationLoss))
Example #6
Source File: losses_builder_test.py From DOTA_models with Apache License 2.0 | 6 votes |
def test_build_weighted_sigmoid_classification_loss(self): losses_text_proto = """ classification_loss { weighted_sigmoid { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSigmoidClassificationLoss))
Example #7
Source File: losses_builder_test.py From DOTA_models with Apache License 2.0 | 6 votes |
def test_build_bootstrapped_sigmoid_classification_loss(self): losses_text_proto = """ classification_loss { bootstrapped_sigmoid { alpha: 0.5 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.BootstrappedSigmoidClassificationLoss))
Example #8
Source File: losses_builder_test.py From object_detector_app with MIT License | 6 votes |
def test_build_bootstrapped_sigmoid_classification_loss(self): losses_text_proto = """ classification_loss { bootstrapped_sigmoid { alpha: 0.5 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.BootstrappedSigmoidClassificationLoss))
Example #9
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_hard_example_miner_for_classification_loss(self): losses_text_proto = """ localization_loss { weighted_l2 { } } classification_loss { weighted_softmax { } } hard_example_miner { loss_type: CLASSIFICATION } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, _, _, _, hard_example_miner = losses_builder.build(losses_proto) self.assertTrue(isinstance(hard_example_miner, losses.HardExampleMiner)) self.assertEqual(hard_example_miner._loss_type, 'cls')
Example #10
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_hard_example_miner_for_localization_loss(self): losses_text_proto = """ localization_loss { weighted_l2 { } } classification_loss { weighted_softmax { } } hard_example_miner { loss_type: LOCALIZATION } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, _, _, _, hard_example_miner, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(hard_example_miner, losses.HardExampleMiner)) self.assertEqual(hard_example_miner._loss_type, 'loc')
Example #11
Source File: losses_builder_test.py From object_detector_app with MIT License | 6 votes |
def test_build_hard_example_miner_for_classification_loss(self): losses_text_proto = """ localization_loss { weighted_l2 { } } classification_loss { weighted_softmax { } } hard_example_miner { loss_type: CLASSIFICATION } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, _, _, _, hard_example_miner = losses_builder.build(losses_proto) self.assertTrue(isinstance(hard_example_miner, losses.HardExampleMiner)) self.assertEqual(hard_example_miner._loss_type, 'cls')
Example #12
Source File: losses_builder_test.py From object_detector_app with MIT License | 6 votes |
def test_build_hard_example_miner_for_localization_loss(self): losses_text_proto = """ localization_loss { weighted_l2 { } } classification_loss { weighted_softmax { } } hard_example_miner { loss_type: LOCALIZATION } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, _, _, _, hard_example_miner = losses_builder.build(losses_proto) self.assertTrue(isinstance(hard_example_miner, losses.HardExampleMiner)) self.assertEqual(hard_example_miner._loss_type, 'loc')
Example #13
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_anchorwise_output(self): losses_text_proto = """ classification_loss { weighted_sigmoid { anchorwise_output: true } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSigmoidClassificationLoss)) predictions = tf.constant([[[0.0, 1.0, 0.0], [0.0, 0.5, 0.5]]]) targets = tf.constant([[[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]]) weights = tf.constant([[1.0, 1.0]]) loss = classification_loss(predictions, targets, weights=weights) self.assertEqual(loss.shape, [1, 2, 3])
Example #14
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_bootstrapped_sigmoid_classification_loss(self): losses_text_proto = """ classification_loss { bootstrapped_sigmoid { alpha: 0.5 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.BootstrappedSigmoidClassificationLoss))
Example #15
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_weighted_softmax_classification_loss_with_logit_scale(self): losses_text_proto = """ classification_loss { weighted_softmax { logit_scale: 2.0 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSoftmaxClassificationLoss))
Example #16
Source File: losses_builder_test.py From object_detector_app with MIT License | 6 votes |
def test_build_weighted_softmax_classification_loss(self): losses_text_proto = """ classification_loss { weighted_softmax { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSoftmaxClassificationLoss))
Example #17
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_weighted_sigmoid_focal_loss_non_default(self): losses_text_proto = """ classification_loss { weighted_sigmoid_focal { alpha: 0.25 gamma: 3.0 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.SigmoidFocalClassificationLoss)) self.assertAlmostEqual(classification_loss._alpha, 0.25) self.assertAlmostEqual(classification_loss._gamma, 3.0)
Example #18
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_l2_localization_loss(self): losses_text_proto = """ localization_loss { weighted_l2 { } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedL2LocalizationLoss))
Example #19
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_smooth_l1_localization_loss_non_default_delta(self): losses_text_proto = """ localization_loss { weighted_smooth_l1 { delta: 0.1 } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedSmoothL1LocalizationLoss)) self.assertAlmostEqual(localization_loss._delta, 0.1)
Example #20
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_iou_localization_loss(self): losses_text_proto = """ localization_loss { weighted_iou { } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedIOULocalizationLoss))
Example #21
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_anchorwise_output(self): losses_text_proto = """ localization_loss { weighted_smooth_l1 { } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedSmoothL1LocalizationLoss)) predictions = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]]) targets = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]]) weights = tf.constant([[1.0, 1.0]]) loss = localization_loss(predictions, targets, weights=weights) self.assertEqual(loss.shape, [1, 2])
Example #22
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_build_weighted_sigmoid_classification_loss(self): losses_text_proto = """ classification_loss { weighted_sigmoid { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSigmoidClassificationLoss))
Example #23
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_sigmoid_classification_loss(self): losses_text_proto = """ classification_loss { weighted_sigmoid { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSigmoidClassificationLoss))
Example #24
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_sigmoid_focal_loss_non_default(self): losses_text_proto = """ classification_loss { weighted_sigmoid_focal { alpha: 0.25 gamma: 3.0 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.SigmoidFocalClassificationLoss)) self.assertAlmostEqual(classification_loss._alpha, 0.25) self.assertAlmostEqual(classification_loss._gamma, 3.0)
Example #25
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_softmax_classification_loss(self): losses_text_proto = """ classification_loss { weighted_softmax { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSoftmaxClassificationLoss))
Example #26
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_logits_softmax_classification_loss(self): losses_text_proto = """ classification_loss { weighted_logits_softmax { } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue( isinstance(classification_loss, losses.WeightedSoftmaxClassificationAgainstLogitsLoss))
Example #27
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_weighted_softmax_classification_loss_with_logit_scale(self): losses_text_proto = """ classification_loss { weighted_softmax { logit_scale: 2.0 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.WeightedSoftmaxClassificationLoss))
Example #28
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_bootstrapped_sigmoid_classification_loss(self): losses_text_proto = """ classification_loss { bootstrapped_sigmoid { alpha: 0.5 } } localization_loss { weighted_l2 { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) classification_loss, _, _, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(classification_loss, losses.BootstrappedSigmoidClassificationLoss))
Example #29
Source File: losses_builder_test.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def test_build_hard_example_miner_for_classification_loss(self): losses_text_proto = """ localization_loss { weighted_l2 { } } classification_loss { weighted_softmax { } } hard_example_miner { loss_type: CLASSIFICATION } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, _, _, _, hard_example_miner, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(hard_example_miner, losses.HardExampleMiner)) self.assertEqual(hard_example_miner._loss_type, 'cls')
Example #30
Source File: losses_builder_test.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def test_anchorwise_output(self): losses_text_proto = """ localization_loss { weighted_smooth_l1 { } } classification_loss { weighted_softmax { } } """ losses_proto = losses_pb2.Loss() text_format.Merge(losses_text_proto, losses_proto) _, localization_loss, _, _, _ = losses_builder.build(losses_proto) self.assertTrue(isinstance(localization_loss, losses.WeightedSmoothL1LocalizationLoss)) predictions = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]]) targets = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]]) weights = tf.constant([[1.0, 1.0]]) loss = localization_loss(predictions, targets, weights=weights) self.assertEqual(loss.shape, [1, 2])