28
28
from object_detection .meta_architectures import rfcn_meta_arch
29
29
from object_detection .meta_architectures import ssd_meta_arch
30
30
from object_detection .models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
31
+ from object_detection .models import faster_rcnn_inception_v2_feature_extractor as frcnn_inc_v2
32
+ from object_detection .models import faster_rcnn_nas_feature_extractor as frcnn_nas
31
33
from object_detection .models import faster_rcnn_resnet_v1_feature_extractor as frcnn_resnet_v1
34
+ from object_detection .models .embedded_ssd_mobilenet_v1_feature_extractor import EmbeddedSSDMobileNetV1FeatureExtractor
32
35
from object_detection .models .ssd_inception_v2_feature_extractor import SSDInceptionV2FeatureExtractor
36
+ from object_detection .models .ssd_inception_v3_feature_extractor import SSDInceptionV3FeatureExtractor
33
37
from object_detection .models .ssd_mobilenet_v1_feature_extractor import SSDMobileNetV1FeatureExtractor
34
38
from object_detection .protos import model_pb2
35
39
36
40
# A map of names to SSD feature extractors.
37
41
SSD_FEATURE_EXTRACTOR_CLASS_MAP = {
38
42
'ssd_inception_v2' : SSDInceptionV2FeatureExtractor ,
43
+ 'ssd_inception_v3' : SSDInceptionV3FeatureExtractor ,
39
44
'ssd_mobilenet_v1' : SSDMobileNetV1FeatureExtractor ,
45
+ 'embedded_ssd_mobilenet_v1' : EmbeddedSSDMobileNetV1FeatureExtractor ,
40
46
}
41
47
42
48
# A map of names to Faster R-CNN feature extractors.
43
49
FASTER_RCNN_FEATURE_EXTRACTOR_CLASS_MAP = {
50
+ 'faster_rcnn_nas' :
51
+ frcnn_nas .FasterRCNNNASFeatureExtractor ,
52
+ 'faster_rcnn_inception_resnet_v2' :
53
+ frcnn_inc_res .FasterRCNNInceptionResnetV2FeatureExtractor ,
54
+ 'faster_rcnn_inception_v2' :
55
+ frcnn_inc_v2 .FasterRCNNInceptionV2FeatureExtractor ,
44
56
'faster_rcnn_resnet50' :
45
57
frcnn_resnet_v1 .FasterRCNNResnet50FeatureExtractor ,
46
58
'faster_rcnn_resnet101' :
47
59
frcnn_resnet_v1 .FasterRCNNResnet101FeatureExtractor ,
48
60
'faster_rcnn_resnet152' :
49
61
frcnn_resnet_v1 .FasterRCNNResnet152FeatureExtractor ,
50
- 'faster_rcnn_inception_resnet_v2' :
51
- frcnn_inc_res .FasterRCNNInceptionResnetV2FeatureExtractor
52
62
}
53
63
54
64
@@ -94,15 +104,18 @@ def _build_ssd_feature_extractor(feature_extractor_config, is_training,
94
104
feature_type = feature_extractor_config .type
95
105
depth_multiplier = feature_extractor_config .depth_multiplier
96
106
min_depth = feature_extractor_config .min_depth
107
+ pad_to_multiple = feature_extractor_config .pad_to_multiple
108
+ batch_norm_trainable = feature_extractor_config .batch_norm_trainable
97
109
conv_hyperparams = hyperparams_builder .build (
98
110
feature_extractor_config .conv_hyperparams , is_training )
99
111
100
112
if feature_type not in SSD_FEATURE_EXTRACTOR_CLASS_MAP :
101
113
raise ValueError ('Unknown ssd feature_extractor: {}' .format (feature_type ))
102
114
103
115
feature_extractor_class = SSD_FEATURE_EXTRACTOR_CLASS_MAP [feature_type ]
104
- return feature_extractor_class (depth_multiplier , min_depth , conv_hyperparams ,
105
- reuse_weights )
116
+ return feature_extractor_class (is_training , depth_multiplier , min_depth ,
117
+ pad_to_multiple , conv_hyperparams ,
118
+ batch_norm_trainable , reuse_weights )
106
119
107
120
108
121
def _build_ssd_model (ssd_config , is_training ):
@@ -180,14 +193,16 @@ def _build_faster_rcnn_feature_extractor(
180
193
feature_type = feature_extractor_config .type
181
194
first_stage_features_stride = (
182
195
feature_extractor_config .first_stage_features_stride )
196
+ batch_norm_trainable = feature_extractor_config .batch_norm_trainable
183
197
184
198
if feature_type not in FASTER_RCNN_FEATURE_EXTRACTOR_CLASS_MAP :
185
199
raise ValueError ('Unknown Faster R-CNN feature_extractor: {}' .format (
186
200
feature_type ))
187
201
feature_extractor_class = FASTER_RCNN_FEATURE_EXTRACTOR_CLASS_MAP [
188
202
feature_type ]
189
203
return feature_extractor_class (
190
- is_training , first_stage_features_stride , reuse_weights )
204
+ is_training , first_stage_features_stride ,
205
+ batch_norm_trainable , reuse_weights )
191
206
192
207
193
208
def _build_faster_rcnn_model (frcnn_config , is_training ):
@@ -248,8 +263,13 @@ def _build_faster_rcnn_model(frcnn_config, is_training):
248
263
) = post_processing_builder .build (frcnn_config .second_stage_post_processing )
249
264
second_stage_localization_loss_weight = (
250
265
frcnn_config .second_stage_localization_loss_weight )
266
+ second_stage_classification_loss = (
267
+ losses_builder .build_faster_rcnn_classification_loss (
268
+ frcnn_config .second_stage_classification_loss ))
251
269
second_stage_classification_loss_weight = (
252
270
frcnn_config .second_stage_classification_loss_weight )
271
+ second_stage_mask_prediction_loss_weight = (
272
+ frcnn_config .second_stage_mask_prediction_loss_weight )
253
273
254
274
hard_example_miner = None
255
275
if frcnn_config .HasField ('hard_example_miner' ):
@@ -286,6 +306,8 @@ def _build_faster_rcnn_model(frcnn_config, is_training):
286
306
'second_stage_score_conversion_fn' : second_stage_score_conversion_fn ,
287
307
'second_stage_localization_loss_weight' :
288
308
second_stage_localization_loss_weight ,
309
+ 'second_stage_classification_loss' :
310
+ second_stage_classification_loss ,
289
311
'second_stage_classification_loss_weight' :
290
312
second_stage_classification_loss_weight ,
291
313
'hard_example_miner' : hard_example_miner }
@@ -300,4 +322,6 @@ def _build_faster_rcnn_model(frcnn_config, is_training):
300
322
maxpool_kernel_size = maxpool_kernel_size ,
301
323
maxpool_stride = maxpool_stride ,
302
324
second_stage_mask_rcnn_box_predictor = second_stage_box_predictor ,
325
+ second_stage_mask_prediction_loss_weight = (
326
+ second_stage_mask_prediction_loss_weight ),
303
327
** common_kwargs )
0 commit comments