Skip to content

Instantly share code, notes, and snippets.

@NobuoTsukamoto
Last active June 28, 2020 16:31
Show Gist options
  • Save NobuoTsukamoto/ac670e1103d58ef77d5f5db284bf43b7 to your computer and use it in GitHub Desktop.
Save NobuoTsukamoto/ac670e1103d58ef77d5f5db284bf43b7 to your computer and use it in GitHub Desktop.
object_detection_ssd mobilenet v3.ipynb
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yanxiangyi
Copy link

Hi! Thanks for the notebook! It works great before the large model. It seems that the large model has some bug. There's no bbox on the bottom images.

@kamae
Copy link

kamae commented Mar 10, 2020

Thank you for the posting.

I have been trying to run to the end of "ssd_mobilenet_v3_small_coco_2020_01_14" on my Centos7 conda env (Py3.6 TF1.12). I get to the code cell starting with "run_detection" but get a serious error stating*
InvalidArgumentError in import_graph_def(graph_def, input_map, return_elements, name, op_dict, producer_op_list)
In my environment I find, print(tf.graph_util.import_graph_def.doc) sayingSOME ARGUMENTS ARE DEPRECATED. They will be removed in a future version.
Instructions for updating:
Please file an issue at https://github.com/tensorflow/tensorflow/issues if you depend on this feature.

I don't find any instruction in the url.

Please help me to fix this issue.

@NobuoTsukamoto
Copy link
Author

@kamae

InvalidArgumentError in import_graph_def(graph_def, input_map, return_elements, name, op_dict, producer_op_list)

Problem is the graph has been compiled for a different version of Tensorflow ( May be TF1.14 or above ). But, graphs cannot be compiled with TF1.12 ( and TF1.13 ). export_inference_graph.py results in an error and freeze graph cannot be executed. Please run with the latest TF1.15.x.

@kamae
Copy link

kamae commented Mar 12, 2020 via email

@kamae
Copy link

kamae commented Mar 13, 2020

Sorry to ask a trivial question:
I changed TF to 1.15.3. But something else bothers me. The problem seems to come from package name registration in Jupyter notebook.
To be specific, I got an error saying:
ImportError: cannot import name 'anchor_generator_pb2' I thought I am in the directory I have prepared.
os.getcwd() > '/home/kamae/Desktop/NTTGCPGithub/models/research'
However import below seems not to work
from object_detection.protos import eval_pb2
I broke down to two steps to get working
import object_detection.protos
from protos import eval_pb2

I am using python3.6.8 and tf1.15.3 setup by conda envs

Thank you.

@NobuoTsukamoto
Copy link
Author

@kamae

Please check the installation.
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

Is the Protobuf libraries installed?
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#protobuf-compilation

If installed, the following commands will not show any errors.

# From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.

If an error occurs, please install or build.
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#manual-protobuf-compiler-installation-and-usage

@kamae
Copy link

kamae commented Mar 14, 2020 via email

@NobuoTsukamoto
Copy link
Author

@kamae さん

すいません。少し質問させてください(難しいところもあり、日本語でお願いします)。

  • "a custum COCO-like dataset"は、ご自身が作成したデータセットでしょうか?または、公開されているデータセットでしょうか?学習に必要なTF-Recodeの作成のハードルが高いと思います。TF-Recodeの作成が必要な場合、create_coco_tf_record.pyをベースに改造が必要と思います。公開されているデータセットであれば手順を示しやすいのです。ご自身が作成した場合、使用したツールの情報があればとは思います。
  • 私はAndroidのアプリには詳しくはありません。TensorFlow Lite Object Detection Android Demoを参考にモデルを入れ替えることぐらいとなります。

既にご存知かもしれませんが、

  • SSD_MobileNetV3を使用するには、最新のtensorflow/modelsのリポジトリを使用してください。
  • 公開されているpre-trained modelには問題(Largeでオブジェクトを検出しない)があります。新しいpre-trained modelへのurlはまだマージされていません。こちらのPull Requestのdownload urlを参考にしてください。なお、このnotebookでのリンクは新しいdownload urlに修正してあります。

@kamae
Copy link

kamae commented Mar 15, 2020

_ was confused about which packages are called. i think I sorted the paths out. Now I am stack by the following error.
File "/home/kamae/Desktop/NTTGCPGithub/models/research/object_detection/builders/model_builder.py", line 179, in _build_ssd_feature_extractor
raise ValueError('Unknown ssd feature_extractor: {}'.format(feature_type))
ValueError: Unknown ssd feature_extractor: ssd_mobilenet_v3_small

Will someone kindly direct me to a new model_builder.py that has an entry for ssd_mobilenet_v3_small/large?

@NobuoTsukamoto
Copy link
Author

@kamae san

Check SSD_FEATURE_EXTRACTOR_CLASS_MAP in models/research/object_detection/builders/model_builder.py.
For the latest master repository, ssd_mobilenet_v3_small and ssd_mobilenet_v3_large are defined as follows. If not, clone the latest repository.

# A map of names to SSD feature extractors.
SSD_FEATURE_EXTRACTOR_CLASS_MAP = {
    'ssd_inception_v2': SSDInceptionV2FeatureExtractor,
    'ssd_inception_v3': SSDInceptionV3FeatureExtractor,
    'ssd_mobilenet_v1': SSDMobileNetV1FeatureExtractor,
    'ssd_mobilenet_v1_fpn': SSDMobileNetV1FpnFeatureExtractor,
    'ssd_mobilenet_v1_ppn': SSDMobileNetV1PpnFeatureExtractor,
    'ssd_mobilenet_v2': SSDMobileNetV2FeatureExtractor,
    'ssd_mobilenet_v2_fpn': SSDMobileNetV2FpnFeatureExtractor,
    'ssd_mobilenet_v3_large': SSDMobileNetV3LargeFeatureExtractor,
    'ssd_mobilenet_v3_small': SSDMobileNetV3SmallFeatureExtractor,
    'ssd_mobilenet_edgetpu': SSDMobileNetEdgeTPUFeatureExtractor,
    'ssd_resnet50_v1_fpn': ssd_resnet_v1_fpn.SSDResnet50V1FpnFeatureExtractor,
    'ssd_resnet101_v1_fpn': ssd_resnet_v1_fpn.SSDResnet101V1FpnFeatureExtractor,
    'ssd_resnet152_v1_fpn': ssd_resnet_v1_fpn.SSDResnet152V1FpnFeatureExtractor,
    'ssd_resnet50_v1_ppn': ssd_resnet_v1_ppn.SSDResnet50V1PpnFeatureExtractor,
    'ssd_resnet101_v1_ppn':
        ssd_resnet_v1_ppn.SSDResnet101V1PpnFeatureExtractor,
    'ssd_resnet152_v1_ppn':
        ssd_resnet_v1_ppn.SSDResnet152V1PpnFeatureExtractor,
    'embedded_ssd_mobilenet_v1': EmbeddedSSDMobileNetV1FeatureExtractor,
    'ssd_pnasnet': SSDPNASNetFeatureExtractor,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment