Skip to content

Commit c9eb355

Browse files
Merged commit includes the following changes: (#8829)
320618558 by rathodv: Internal Change. -- 320597532 by ronnyvotel: Exposing DensePose visualizations to model_lib_v2.py. -- 320533669 by ronnyvotel: Adding utilities to visualize DensePose outputs. -- 320529647 by lzc: Fix saved_model issue in object_detection_tutorial notebook. -- 320510127 by aom: Internal change. -- 320490236 by derekjchow: Update Dockerfiles to use setup.py -- 320443572 by rathodv: Update `Tensorflow` to `TensorFlow` in documentation. -- 320426460 by ronnyvotel: DensePose proto and model builder. -- 320352611 by rathodv: Update documentation to reflect the support for TF1 and TF2. Provide separate sets of instructions to reduce confusion. -- 320350724 by rathodv: Internal Change. -- PiperOrigin-RevId: 320618558 Co-authored-by: kmindspark <[email protected]>
1 parent 950ebc4 commit c9eb355

17 files changed

+600
-332
lines changed

Diff for: research/object_detection/.gitignore

-1
This file was deleted.

Diff for: research/object_detection/CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Contributing to the Tensorflow Object Detection API
1+
# Contributing to the TensorFlow Object Detection API
22

3-
Patches to Tensorflow Object Detection API are welcome!
3+
Patches to TensorFlow Object Detection API are welcome!
44

55
We require contributors to fill out either the individual or corporate
66
Contributor License Agreement (CLA).
@@ -9,5 +9,5 @@ Contributor License Agreement (CLA).
99
* If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html).
1010

1111
Please follow the
12-
[Tensorflow contributing guidelines](https://github.com/tensorflow/tensorflow/blob/master/CONTRIBUTING.md)
12+
[TensorFlow contributing guidelines](https://github.com/tensorflow/tensorflow/blob/master/CONTRIBUTING.md)
1313
when submitting pull requests.

Diff for: research/object_detection/builders/model_builder.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,22 @@ def mask_proto_to_params(mask_config):
870870
heatmap_bias_init=mask_config.heatmap_bias_init)
871871

872872

873+
def densepose_proto_to_params(densepose_config):
874+
"""Converts CenterNet.DensePoseEstimation proto to parameter namedtuple."""
875+
classification_loss, localization_loss, _, _, _, _, _ = (
876+
losses_builder.build(densepose_config.loss))
877+
return center_net_meta_arch.DensePoseParams(
878+
class_id=densepose_config.class_id,
879+
classification_loss=classification_loss,
880+
localization_loss=localization_loss,
881+
part_loss_weight=densepose_config.part_loss_weight,
882+
coordinate_loss_weight=densepose_config.coordinate_loss_weight,
883+
num_parts=densepose_config.num_parts,
884+
task_loss_weight=densepose_config.task_loss_weight,
885+
upsample_to_input_res=densepose_config.upsample_to_input_res,
886+
heatmap_bias_init=densepose_config.heatmap_bias_init)
887+
888+
873889
def _build_center_net_model(center_net_config, is_training, add_summaries):
874890
"""Build a CenterNet detection model.
875891
@@ -922,6 +938,11 @@ def _build_center_net_model(center_net_config, is_training, add_summaries):
922938
if center_net_config.HasField('mask_estimation_task'):
923939
mask_params = mask_proto_to_params(center_net_config.mask_estimation_task)
924940

941+
densepose_params = None
942+
if center_net_config.HasField('densepose_estimation_task'):
943+
densepose_params = densepose_proto_to_params(
944+
center_net_config.densepose_estimation_task)
945+
925946
return center_net_meta_arch.CenterNetMetaArch(
926947
is_training=is_training,
927948
add_summaries=add_summaries,
@@ -931,7 +952,8 @@ def _build_center_net_model(center_net_config, is_training, add_summaries):
931952
object_center_params=object_center_params,
932953
object_detection_params=object_detection_params,
933954
keypoint_params_dict=keypoint_params_dict,
934-
mask_params=mask_params)
955+
mask_params=mask_params,
956+
densepose_params=densepose_params)
935957

936958

937959
def _build_center_net_feature_extractor(

Diff for: research/object_detection/builders/model_builder_tf2_test.py

+39
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,28 @@ def get_fake_mask_proto(self):
164164
return text_format.Merge(proto_txt,
165165
center_net_pb2.CenterNet.MaskEstimation())
166166

167+
def get_fake_densepose_proto(self):
168+
proto_txt = """
169+
task_loss_weight: 0.5
170+
class_id: 0
171+
loss {
172+
classification_loss {
173+
weighted_softmax {}
174+
}
175+
localization_loss {
176+
l1_localization_loss {
177+
}
178+
}
179+
}
180+
num_parts: 24
181+
part_loss_weight: 1.0
182+
coordinate_loss_weight: 2.0
183+
upsample_to_input_res: true
184+
heatmap_bias_init: -2.0
185+
"""
186+
return text_format.Merge(proto_txt,
187+
center_net_pb2.CenterNet.DensePoseEstimation())
188+
167189
def test_create_center_net_model(self):
168190
"""Test building a CenterNet model from proto txt."""
169191
proto_txt = """
@@ -195,6 +217,8 @@ def test_create_center_net_model(self):
195217
self.get_fake_label_map_file_path())
196218
config.center_net.mask_estimation_task.CopyFrom(
197219
self.get_fake_mask_proto())
220+
config.center_net.densepose_estimation_task.CopyFrom(
221+
self.get_fake_densepose_proto())
198222

199223
# Build the model from the configuration.
200224
model = model_builder.build(config, is_training=True)
@@ -251,6 +275,21 @@ def test_create_center_net_model(self):
251275
self.assertAlmostEqual(
252276
model._mask_params.heatmap_bias_init, -2.0, places=4)
253277

278+
# Check DensePose related parameters.
279+
self.assertEqual(model._densepose_params.class_id, 0)
280+
self.assertIsInstance(model._densepose_params.classification_loss,
281+
losses.WeightedSoftmaxClassificationLoss)
282+
self.assertIsInstance(model._densepose_params.localization_loss,
283+
losses.L1LocalizationLoss)
284+
self.assertAlmostEqual(model._densepose_params.part_loss_weight, 1.0)
285+
self.assertAlmostEqual(model._densepose_params.coordinate_loss_weight, 2.0)
286+
self.assertEqual(model._densepose_params.num_parts, 24)
287+
self.assertAlmostEqual(model._densepose_params.task_loss_weight, 0.5)
288+
self.assertTrue(model._densepose_params.upsample_to_input_res)
289+
self.assertEqual(model._densepose_params.upsample_method, 'bilinear')
290+
self.assertAlmostEqual(
291+
model._densepose_params.heatmap_bias_init, -2.0, places=4)
292+
254293
# Check feature extractor parameters.
255294
self.assertIsInstance(
256295
model._feature_extractor,

0 commit comments

Comments
 (0)