models icon indicating copy to clipboard operation
models copied to clipboard

object_detection: executing train.py throws ValueError

Open siddhartha-iitd opened this issue 9 years ago • 13 comments

System information

OS: Linux Ubuntu 16.04 Python: 3.5 TensorFlow version: 1.2.0 tensorflow-gpu installed using pip3

On executing train.py using following command:


python3 object_detection/train.py \
     --logtostderr \
     --pipeline_config_path=data/ssd_inception_v2_pets.config \
     --train_dir=/home/d3/imgs/train

I got the following error:


Traceback (most recent call last):
  File "object_detection/train.py", line 199, in 
    tf.app.run()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "object_detection/train.py", line 195, in main
    worker_job_name, is_chief, FLAGS.train_dir)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/models/object_detection/trainer.py", line 159, in train
    detection_model = create_model_fn()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/models/object_detection/builders/model_builder.py", line 71, in build
    raise ValueError('model_config not of type model_pb2.DetectionModel.')
ValueError: model_config not of type model_pb2.DetectionModel.

I also checked the build method inside object_detection.builders.model_builder module for any issue with model_config argument. print(model_config) command inside the method prints the contents of ssd_inception_v2_pets.config file. However, print(model_pb2.DetectionModel) command inside the build method prints <class 'object_detection.protos.model_pb2.DetectionModel'>

siddhartha-iitd avatar Jun 20 '17 19:06 siddhartha-iitd

I believe this is a duplicate of https://github.com/tensorflow/models/issues/1597

It looks like python3 support for object_detection is being added here: https://github.com/tensorflow/models/pull/1614

tatatodd avatar Jun 20 '17 20:06 tatatodd

I did a fresh installation of Tensorflow and the Protobuf compiler. That solved the issue.

siddhartha-iitd avatar Jun 20 '17 21:06 siddhartha-iitd

I did fresh installation but it didnt work for me. Tensorflow: 1.3.0 libprotoc 3.1.0 Error message: Traceback (most recent call last): File "train.py", line 200, in tf.app.run() File "/home/samir/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "train.py", line 196, in main worker_job_name, is_chief, FLAGS.train_dir) File "/home/samir/tensorflow/models/models/object_detection/trainer.py", line 159, in train detection_model = create_model_fn() File "/home/samir/tensorflow/models/models/object_detection/builders/model_builder.py", line 73, in build raise ValueError('model_config not of type model_pb2.DetectionModel.')

Samir692 avatar Sep 11 '17 18:09 Samir692

ilenetV1/Conv2d_9_depthwise/BatchNorm/moving_mean] not available in checkpoint WARNING:root:Variable [MobilenetV1/Conv2d_9_depthwise/BatchNorm/moving_variance] not available in checkpoint WARNING:root:Variable [MobilenetV1/Conv2d_9_depthwise/depthwise_weights] not available in checkpoint WARNING:root:Variable [MobilenetV1/Conv2d_9_pointwise/BatchNorm/beta] not available in checkpoint WARNING:root:Variable [MobilenetV1/Conv2d_9_pointwise/BatchNorm/gamma] not available in checkpoint WARNING:root:Variable [MobilenetV1/Conv2d_9_pointwise/BatchNorm/moving_mean] not available in checkpoint WARNING:root:Variable [MobilenetV1/Conv2d_9_pointwise/BatchNorm/moving_variance] not available in checkpoint WARNING:root:Variable [MobilenetV1/Conv2d_9_pointwise/weights] not available in checkpoint Traceback (most recent call last): File "train.py", line 163, in tf.app.run() File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "train.py", line 159, in main worker_job_name, is_chief, FLAGS.train_dir) File "/home/ec2-user/sample-notebooks/models/research/object_detection/trainer.py", line 255, in train init_saver = tf.train.Saver(available_var_map) File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1218, in init self.build() File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1227, in build self._build(self._filename, build_save=True, build_restore=True) File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1251, in _build raise ValueError("No variables to save") ValueError: No variables to save

nagrajmss avatar Dec 07 '17 12:12 nagrajmss

how do you get this fixed

nagrajmss avatar Dec 07 '17 12:12 nagrajmss

I am also facing same issue as @nagrajmss , can anybody tell us about this ?

ChiranjeeviBhagavan avatar Feb 07 '18 17:02 ChiranjeeviBhagavan

TypeError: Cannot convert a list containing a tensor of dtype <dtype: 'int32'> to <dtype: 'float32'> (Tensor is: <tf.Tensor 'Preprocessor/stack_1:0' shape=(1, 3) dtype=int32>)

tamizharasank avatar Jul 20 '18 11:07 tamizharasank

For me Environmental variable problem. after setting it properly. it worked.

prasaathviki avatar Oct 28 '18 14:10 prasaathviki

For me Environmental variable problem. after setting it properly. it worked.

how fixed it friend? help me please.

LyonOconner avatar Oct 31 '18 22:10 LyonOconner

how do guys fixed this error If you don't reply i will kill myself

navinthenapster avatar Nov 14 '18 11:11 navinthenapster

In windows, Try setting the tensorflow models in environmental path.

SET _includepath1="C:\tensorflowmodels"
SET _includepath2="C:\tensorflowmodels\research"
SET _includepath3="C:\tensorflowmodels\research\slim"
SET _includepath4="C:\tensorflowmodels\research\object_detection"
SET _includepath5="C:\tensorflowmodels\research\object_detection\protos"
set PYTHONPATH=%_includepath1%;%_includepath2%;%_includepath3%;%_includepath4%;%_includepath5%
set PATH=%PATH%;PYTHONPATH
set _trainpath="C:\train"
set _configfile="C:\train\pipeline.config"
python "..\tensorflowmodels\research\object_detection\legacy\train.py" --logtostderr --train_dir=%_trainpath% --pipeline_config_path=%_configfile%

prasaathviki avatar Nov 15 '18 10:11 prasaathviki

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

OliverSeth avatar Aug 20 '19 08:08 OliverSeth

Its not working .. (tensorflow) D:\my-work\WiS - alert - 2\models\research\object_detection>python train.py --logtostderr --train_dir= D:/my-work/WiS - alert - 2 /models/research/object_detection/training/ --pipeline_config_path= D:/my-work/WiS - alert - 2 /models/research/object_detection/training/ssd_mobilenet_v1_coco.config D:\installation\anaconda\envs\tensorflow\lib\site-packages\h5py_init_.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Traceback (most recent call last): File "train.py", line 164, in tf.app.run() File "D:\installation\anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "train.py", line 88, in main assert FLAGS.train_dir, 'train_dir is missing.' AssertionError: train_dir is missing.

pamrani avatar Dec 26 '19 04:12 pamrani