Unverified Commit 451906e4 authored by pkulzc's avatar pkulzc Committed by GitHub
Browse files

Release MobileDet code and model, and require tf_slim installation for OD API. (#8562)

* Merged commit includes the following changes:
311933687  by Sergio Guadarrama:

    Removes spurios use of tf.compat.v2, which results in spurious tf.compat.v1.compat.v2. Adds basic test to nasnet_utils.
    Replaces all remaining import tensorflow as tf with import tensorflow.compat.v1 as tf

--
311766063  by Sergio Guadarrama:

    Removes explicit tf.compat.v1 in all call sites (we already import tf.compat.v1, so this code was  doing tf.compat.v1.compat.v1). The existing code worked in latest version of tensorflow, 2.2, (and 1.15) but not in 1.14 or in 2.0.0a, this CL fixes it.

--
311624958  by Sergio Guadarrama:

    Updates README that doesn't render properly in github documentation

--
310980959  by Sergio Guadarrama:

    Moves research_models/slim off tf.contrib.slim/layers/framework to tf_slim

--
310263156  by Sergio Guadarrama:

    Adds model breakdown for MobilenetV3

--
308640...
parent 73b5be67
......@@ -16,7 +16,7 @@
"""SSDFeatureExtractor for MobilenetV2 features."""
import tensorflow as tf
import tensorflow.compat.v1 as tf
from object_detection.meta_architectures import ssd_meta_arch
from object_detection.models import feature_map_generators
......
......@@ -22,16 +22,15 @@ from __future__ import print_function
import collections
import functools
from six.moves import range
import tensorflow as tf
import tensorflow.compat.v1 as tf
from tensorflow.contrib import slim as contrib_slim
import tf_slim as slim
from object_detection.meta_architectures import ssd_meta_arch
from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets.mobilenet import mobilenet
from nets.mobilenet import mobilenet_v2
slim = contrib_slim
Block = collections.namedtuple(
'Block', ['inputs', 'output_level', 'kernel_size', 'expansion_size'])
......
......@@ -15,14 +15,11 @@
# ==============================================================================
"""Tests for ssd_mobilenet_v2_nas_fpn_feature_extractor."""
import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from tensorflow.contrib import slim as contrib_slim
from object_detection.models import ssd_feature_extractor_test
from object_detection.models import ssd_mobilenet_v2_mnasfpn_feature_extractor as mnasfpn_feature_extractor
slim = contrib_slim
class SsdMobilenetV2MnasFPNFeatureExtractorTest(
ssd_feature_extractor_test.SsdFeatureExtractorTestBase):
......
......@@ -14,8 +14,8 @@
# ==============================================================================
"""SSDFeatureExtractor for MobileNetV3 features."""
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
import tf_slim as slim
from object_detection.meta_architectures import ssd_meta_arch
from object_detection.models import feature_map_generators
......@@ -25,8 +25,6 @@ from object_detection.utils import shape_utils
from nets.mobilenet import mobilenet
from nets.mobilenet import mobilenet_v3
slim = contrib_slim
class SSDMobileNetV3FeatureExtractorBase(ssd_meta_arch.SSDFeatureExtractor):
"""Base class of SSD feature extractor using MobilenetV3 features."""
......
......@@ -14,14 +14,14 @@
# ==============================================================================
"""Tests for ssd_mobilenet_v3_feature_extractor."""
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
import tf_slim as slim
from object_detection.models import ssd_mobilenet_v3_feature_extractor
from object_detection.models import ssd_mobilenet_v3_feature_extractor_testbase
slim = contrib_slim
slim = slim
class SsdMobilenetV3LargeFeatureExtractorTest(
......
......@@ -17,15 +17,11 @@
import abc
import numpy as np
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
from object_detection.models import ssd_feature_extractor_test
slim = contrib_slim
class _SsdMobilenetV3FeatureExtractorTestBase(
ssd_feature_extractor_test.SsdFeatureExtractorTestBase):
"""Base class for MobilenetV3 tests."""
......
......@@ -19,8 +19,8 @@
Based on PNASNet ImageNet model: https://arxiv.org/abs/1712.00559
"""
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
import tf_slim as slim
from object_detection.meta_architectures import ssd_meta_arch
from object_detection.models import feature_map_generators
......@@ -29,8 +29,6 @@ from object_detection.utils import ops
from object_detection.utils import variables_helper
from nets.nasnet import pnasnet
slim = contrib_slim
def pnasnet_large_arg_scope_for_detection(is_batch_norm_training=False):
"""Defines the default arg scope for the PNASNet Large for object detection.
......
......@@ -15,14 +15,11 @@
"""Tests for ssd_pnas_feature_extractor."""
import numpy as np
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
from object_detection.models import ssd_feature_extractor_test
from object_detection.models import ssd_pnasnet_feature_extractor
slim = contrib_slim
class SsdPnasNetFeatureExtractorTest(
ssd_feature_extractor_test.SsdFeatureExtractorTestBase):
......
......@@ -23,8 +23,8 @@ from __future__ import division
from __future__ import print_function
from six.moves import range
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
import tf_slim as slim
from object_detection.meta_architectures import ssd_meta_arch
from object_detection.models import feature_map_generators
......@@ -33,8 +33,6 @@ from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import resnet_v1
slim = contrib_slim
class SSDResnetV1FpnFeatureExtractor(ssd_meta_arch.SSDFeatureExtractor):
"""SSD FPN feature extractor based on Resnet v1 architecture."""
......
......@@ -13,7 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Tests for ssd resnet v1 FPN feature extractors."""
import tensorflow as tf
import tensorflow.compat.v1 as tf
from object_detection.models import ssd_resnet_v1_fpn_feature_extractor
from object_detection.models import ssd_resnet_v1_fpn_feature_extractor_testbase
......
......@@ -22,7 +22,7 @@ import abc
from absl.testing import parameterized
import numpy as np
from six.moves import zip
import tensorflow as tf
import tensorflow.compat.v1 as tf
from object_detection.models import ssd_feature_extractor_test
......
......@@ -22,7 +22,7 @@ from __future__ import print_function
from six.moves import range
from six.moves import zip
import tensorflow as tf
import tensorflow.compat.v1 as tf
from object_detection.meta_architectures import ssd_meta_arch
from object_detection.models import feature_map_generators
......
......@@ -15,8 +15,8 @@
# ==============================================================================
"""SSD feature extractors based on Resnet v1 and PPN architectures."""
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
import tf_slim as slim
from object_detection.meta_architectures import ssd_meta_arch
from object_detection.models import feature_map_generators
......@@ -25,8 +25,6 @@ from object_detection.utils import ops
from object_detection.utils import shape_utils
from nets import resnet_v1
slim = contrib_slim
class _SSDResnetPpnFeatureExtractor(ssd_meta_arch.SSDFeatureExtractor):
"""SSD feature extractor based on resnet architecture and PPN."""
......
......@@ -13,7 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Tests for ssd resnet v1 feature extractors."""
import tensorflow as tf
import tensorflow.compat.v1 as tf
from object_detection.models import ssd_resnet_v1_ppn_feature_extractor
from object_detection.models import ssd_resnet_v1_ppn_feature_extractor_testbase
......
......@@ -15,7 +15,7 @@
"""Tests for ssd resnet v1 feature extractors."""
import abc
import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from object_detection.models import ssd_feature_extractor_test
......
......@@ -21,14 +21,12 @@ from __future__ import print_function
import functools
from six.moves import range
from six.moves import zip
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
import tf_slim as slim
from object_detection.core import box_predictor
from object_detection.utils import shape_utils
from object_detection.utils import static_shape
slim = contrib_slim
BOX_ENCODINGS = box_predictor.BOX_ENCODINGS
CLASS_PREDICTIONS_WITH_BACKGROUND = (
box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND)
......
......@@ -24,7 +24,7 @@ from absl.testing import parameterized
import numpy as np
from six.moves import range
from six.moves import zip
import tensorflow as tf
import tensorflow.compat.v1 as tf
from google.protobuf import text_format
from object_detection.builders import box_predictor_builder
......
......@@ -22,7 +22,7 @@ from __future__ import print_function
import collections
from six.moves import range
import tensorflow as tf
import tensorflow.compat.v1 as tf
from object_detection.core import box_predictor
from object_detection.utils import shape_utils
......
......@@ -15,7 +15,7 @@
"""Tests for object_detection.predictors.convolutional_keras_box_predictor."""
import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf
from google.protobuf import text_format
from object_detection.builders import box_predictor_builder
......
......@@ -20,13 +20,11 @@ All the box prediction heads have a predict function that receives the
`features` as the first argument and returns `box_encodings`.
"""
import functools
import tensorflow as tf
from tensorflow.contrib import slim as contrib_slim
import tensorflow.compat.v1 as tf
import tf_slim as slim
from object_detection.predictors.heads import head
slim = contrib_slim
class MaskRCNNBoxHead(head.Head):
"""Box prediction head.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment