1

Im currently working on a tensorflow project and I am getting this error.

ValueError: model_config not of type model_pb2.DetectionModel.

It happens when I'm trying to train my model. Has anyone encountered this issue before? First question asked on here so be gentle.

`Chinatowns-MacBook-Air:object_detection nathangrant$ python3 train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.7
  return f(*args, **kwds)
WARNING:tensorflow:From /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/platform/app.py:48: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
Traceback (most recent call last):
  File "train.py", line 184, in <module>
    tf.app.run()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 136, in new_func
    return func(*args, **kwargs)
  File "train.py", line 180, in main
    graph_hook_fn=graph_rewriter_fn)
  File "/Users/nathangrant/Downloads/models-master/research/object_detection/legacy/trainer.py", line 245, in train
    detection_model = create_model_fn()
  File "/Users/nathangrant/Downloads/models-master/research/object_detection/builders/model_builder.py", line 105, in build
    raise ValueError('model_config not of type model_pb2.DetectionModel.')
ValueError: model_config not of type model_pb2.DetectionModel.`
whoosis
  • 454
  • 7
  • 25

2 Answers2

0

Try this first,

Solution A:

  1. Download this complete "models_shareToPublic".rar file.
  2. Unzip/Unrar the file.
  3. Copy all the contains of the folder to your project library directory
  4. Run your code/program again.

Solution B:

  1. Please open the cmd prompt in your project library directory In my case, it is: (my_project_name\venv\Lib\site-packages)

  2. Clone the master branch of the Tensorflow Models repository by typing the cmd command below in the cmd prompt, which is opened in the specified directory above. (might take a few minutes depending on your network speed)

git clone https://github.com/tensorflow/models.git

  1. Move all the contents inside the models folder into the library directory stated in Step 1.
  2. Create "*.pb2" files by following this steps
  3. Change the import line below in model_builder.py

Change from this:

from protos import model_pb2

to this:

from object_detection.protos import model_pb2

  1. Run your code/program again, and you will notice this same error will be disappeared.

Notes: If it appears

  • ModuleNotFoundError: No module named 'object_detection'

    Go to "research" folder and copy the "object_detection" folder to the directory same with "research" folder. So that it can call the library directly, if not, you have to adjust the import line in each .py file (very wasting time)

Hope it works to you too, Good Luck!

Jay Jay
  • 33
  • 6
-1

In my computer, I did these and fixed this problem:

In model_builder.py, don't use

from protos import model_pb2

use

from object_detection.protos import model_pb2

instead.

rsm
  • 2,530
  • 4
  • 26
  • 33
Oliver
  • 11