models icon indicating copy to clipboard operation
models copied to clipboard

[Object Detection] Assign requires shapes of both tensors to match.

Open Manish-rai21bit opened this issue 8 years ago • 15 comments

Please go to Stack Overflow for help and support:

http://stackoverflow.com/questions/tagged/tensorflow

Also, please understand that many of the models included in this repository are experimental and research-style code. If you open a GitHub issue, here is our policy:

  1. It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
  2. The form below must be filled out.

Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.


System information

  • What is the top-level directory of the model you are using: tensorflow/models/research
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac OS 10.13.6
  • TensorFlow installed from (source or binary): pip install
  • TensorFlow version (use command below): 1.9
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory: No
  • Exact command to reproduce: python object_detection/model_main.py --pipeline_config_path=${PIPELINE_CONFIG_PATH} --model_dir=${MODEL_DIR} --num_train_steps=${NUM_TRAIN_STEPS} --num_eval_steps=${NUM_EVAL_STEPS} --alsologtostderr

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the problem

I am trying to train an object detection task using the ssd_mobilenet_v1_coco_2018_01_28 model. I am following the instructions given here (https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_locally.md). I have a directory structure that looks like this: +data

  • train.tfrecord
  • test.tfrecord
  • label_map.pbtxt +models ++ ssd_mobilenet_v1_coco_2018_01_28 -checkpoints -frozen_inference_graph.pb -model.ckpt -pipeline.config

Source code / logs

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/init.py:34: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._conv import register_converters as _register_converters /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/init.py:34: 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 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/init.py:43: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import h5a, h5d, h5ds, h5f, h5fd, h5g, h5r, h5s, h5t, h5p, h5z /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_hl/group.py:24: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from .. import h5g, h5i, h5o, h5r, h5t, h5l, h5p /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/sparse/lil.py:16: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import _csparsetools /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/sparse/csgraph/init.py:167: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._shortest_path import shortest_path, floyd_warshall, dijkstra,
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/sparse/csgraph/_validation.py:5: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._tools import csgraph_to_dense, csgraph_from_dense,
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/sparse/csgraph/init.py:169: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._traversal import breadth_first_order, depth_first_order,
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/sparse/csgraph/init.py:171: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._min_spanning_tree import minimum_spanning_tree /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/sparse/csgraph/init.py:172: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._reordering import reverse_cuthill_mckee, maximum_bipartite_matching,
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/basic.py:17: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._solve_toeplitz import levinson /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/init.py:191: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._decomp_update import * /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/special/init.py:640: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._ufuncs import * /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/special/_ellip_harm.py:7: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/optimize/_numdiff.py:8: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._group_columns import group_dense, group_sparse /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/interpolate/_bsplines.py:9: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import _bspl /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/spatial/init.py:94: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from .ckdtree import * /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/spatial/init.py:95: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from .qhull import * /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/spatial/_spherical_voronoi.py:18: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import _voronoi /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/spatial/distance.py:121: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import _hausdorff /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/ndimage/measurements.py:36: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import _ni_label /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/init.py:7: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility from . import hashtable, tslib, lib /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/init.py:7: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility from . import hashtable, tslib, lib /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/index.py:13: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility import pandas.index as _index /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/index.py:13: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility import pandas.index as _index /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/sparse/array.py:16: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility from pandas._sparse import BlockIndex, IntIndex /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/sparse/array.py:16: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility from pandas._sparse import BlockIndex, IntIndex /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/parsers.py:26: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility import pandas.parser as _parser /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/parsers.py:26: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility import pandas.parser as _parser /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/packers.py:63: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility from pandas.msgpack import Unpacker as _Unpacker, Packer as _Packer /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/packers.py:63: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility from pandas.msgpack import Unpacker as _Unpacker, Packer as _Packer /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/init.py:1405: UserWarning: This call to matplotlib.use() has no effect because the backend has already been chosen; matplotlib.use() must be called before pylab, matplotlib.pyplot, or matplotlib.backends is imported for the first time.

warnings.warn(_use_error_msg) /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/init.py:10: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from .murmurhash import murmurhash3_32 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/init.py:10: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192, got 176 from .murmurhash import murmurhash3_32 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/stats/_continuous_distns.py:17: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import _stats /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/extmath.py:24: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from ._logistic_sigmoid import _log_logistic_sigmoid /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/extmath.py:24: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192, got 176 from ._logistic_sigmoid import _log_logistic_sigmoid /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/extmath.py:26: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from .sparsefuncs_fast import csr_row_norms /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/extmath.py:26: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192, got 176 from .sparsefuncs_fast import csr_row_norms /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/metrics/cluster/supervised.py:24: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from .expected_mutual_info_fast import expected_mutual_information /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/metrics/cluster/supervised.py:24: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192, got 176 from .expected_mutual_info_fast import expected_mutual_information /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/metrics/pairwise.py:29: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from .pairwise_fast import _chi2_kernel_fast, _sparse_manhattan /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/metrics/pairwise.py:29: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192, got 176 from .pairwise_fast import _chi2_kernel_fast, _sparse_manhattan WARNING:tensorflow:Estimator's model_fn (<function model_fn at 0x123ea92a8>) includes params argument, but params are not passed to Estimator. 2018-08-13 20:12:12.931472: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA Traceback (most recent call last): File "object_detection/model_main.py", line 101, in tf.app.run() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "object_detection/model_main.py", line 97, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 447, in train_and_evaluate return executor.run() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 531, in run return self.run_local() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 681, in run_local eval_result, export_results = evaluator.evaluate_and_export() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 886, in evaluate_and_export hooks=self._eval_spec.hooks) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/estimator.py", line 460, in evaluate output_dir=self.eval_dir(name)) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/estimator.py", line 1386, in _evaluate_run config=self._session_config) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/evaluation.py", line 209, in _evaluate_once session_creator=session_creator, hooks=hooks) as session: File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 826, in init stop_grace_period_secs=stop_grace_period_secs) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 549, in init self._sess = _RecoverableSession(self._coordinated_creator) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 1012, in init _WrappedSession.init(self, self._create_session()) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 1017, in _create_session return self._sess_creator.create_session() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 706, in create_session self.tf_sess = self._session_creator.create_session() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 477, in create_session init_fn=self._scaffold.init_fn) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/session_manager.py", line 281, in prepare_session config=config) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/session_manager.py", line 195, in _restore_checkpoint saver.restore(sess, checkpoint_filename_with_path) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 1752, in restore {self.saver_def.filename_tensor_name: save_path}) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 900, in run run_metadata_ptr) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 1135, in _run feed_dict_tensor, options, run_metadata) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run run_metadata) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1,1,512,141] rhs shape= [1,1,512,273] [[Node: save/Assign_3 = Assign[T=DT_FLOAT, _class=["loc:@BoxPredictor_0/ClassPredictor/weights"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](BoxPredictor_0/ClassPredictor/weights, save/RestoreV2:3)]]

Caused by op u'save/Assign_3', defined at: File "object_detection/model_main.py", line 101, in tf.app.run() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "object_detection/model_main.py", line 97, in main tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0]) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 447, in train_and_evaluate return executor.run() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 531, in run return self.run_local() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 681, in run_local eval_result, export_results = evaluator.evaluate_and_export() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/training.py", line 886, in evaluate_and_export hooks=self._eval_spec.hooks) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/estimator.py", line 460, in evaluate output_dir=self.eval_dir(name)) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/estimator/estimator.py", line 1386, in _evaluate_run config=self._session_config) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/evaluation.py", line 209, in _evaluate_once session_creator=session_creator, hooks=hooks) as session: File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 826, in init stop_grace_period_secs=stop_grace_period_secs) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 549, in init self._sess = _RecoverableSession(self._coordinated_creator) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 1012, in init _WrappedSession.init(self, self._create_session()) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 1017, in _create_session return self._sess_creator.create_session() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 706, in create_session self.tf_sess = self._session_creator.create_session() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 468, in create_session self._scaffold.finalize() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/monitored_session.py", line 212, in finalize self._saver = training_saver._get_saver_or_default() # pylint: disable=protected-access File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 856, in _get_saver_or_default saver = Saver(sharded=True, allow_empty=True) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 1284, in init self.build() File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 1296, in build self._build(self._filename, build_save=True, build_restore=True) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 1333, in _build build_save=build_save, build_restore=build_restore) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 775, in _build_internal restore_sequentially, reshape) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 453, in _AddShardedRestoreOps name="restore_shard")) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 422, in _AddRestoreOps assign_ops.append(saveable.restore(saveable_tensors, shapes)) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/training/saver.py", line 113, in restore self.op.get_shape().is_fully_defined()) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/ops/state_ops.py", line 219, in assign validate_shape=validate_shape) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/ops/gen_state_ops.py", line 60, in assign use_locking=use_locking, name=name) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/framework/ops.py", line 3414, in create_op op_def=op_def) File "/Users/manishrai/Library/Python/2.7/lib/python/site-packages/tensorflow/python/framework/ops.py", line 1740, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1,1,512,141] rhs shape= [1,1,512,273] [[Node: save/Assign_3 = Assign[T=DT_FLOAT, _class=["loc:@BoxPredictor_0/ClassPredictor/weights"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](BoxPredictor_0/ClassPredictor/weights, save/RestoreV2:3)]]

Manish-rai21bit avatar Aug 14 '18 01:08 Manish-rai21bit

Also, if I run the training in Python3.. I get this error.. ImportError: dlopen(~/Code/tensorflow/models/research/pycocotools/_mask.so, 2): Symbol not found: _PyCObject_Type

Manish-rai21bit avatar Aug 14 '18 17:08 Manish-rai21bit

Do you have anything in the model dir before running the command?

k-w-w avatar Aug 16 '18 00:08 k-w-w

The model(names as - ssd_mobilenet_v1_coco_2018_01_28) directory has the following files:

  1. checkpoint
  2. frozen_inference_graph.pb
  3. model.ckpt.data-00000-of-00001
  4. model.ckpt.index
  5. model.ckpt.meta
  6. pipeline.config
  7. saved_model(folder)

I downloaded this model(ssd_mobilenet_v1_coco_2018_01_28) from this link and made changes to the pipeline.config file to reflect my data.

My dataset has 2 classes and I am trying to use the ssd_mobilenet model and retrain it for my 2 class object detection.

I have the following fields in the tfrecord example(in line with the documentation on the object detection API): 'image/height': dataset_util.int64_feature(height), 'image/width': dataset_util.int64_feature(width), 'image/filename': dataset_util.bytes_feature(filename), 'image/source_id': dataset_util.bytes_feature(filename), 'image/encoded': dataset_util.bytes_feature(encoded_jpg), 'image/format': dataset_util.bytes_feature(image_format), 'image/object/bbox/xmin': dataset_util.float_list_feature(xmins), 'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs), 'image/object/bbox/ymin': dataset_util.float_list_feature(ymins), 'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs), 'image/object/class/text': dataset_util.bytes_list_feature(classes_text), 'image/object/class/label': dataset_util.int64_list_feature(classes), }))

Manish-rai21bit avatar Aug 16 '18 03:08 Manish-rai21bit

Hi,

I have been able to solve the issue by changing the directory structure. You may close the issue. However, I do not understand why having a different directory structure will be a problem as long as I use the correct paths in the config file!

Manish-rai21bit avatar Aug 21 '18 00:08 Manish-rai21bit

@Manish-rai21bit Could you please describe your solution more detail? I have the same problem.

kulsemig avatar Aug 21 '18 03:08 kulsemig

Hi @kulsemig. I put my workspace directory inside /tensorflow/models/. Inside my workspace directory I have:

  • annotation - having label map, train and test label record
  • images --train images -- test images
  • pretrained-model - where you download the pretrained model and paste the content in it
  • trained-inference-graph - where the trained graph gets exported
  • training - where the trained model checkpoint will get saved

Manish-rai21bit avatar Aug 21 '18 15:08 Manish-rai21bit

Hi @Manish-rai21bit. Unfortunately, it did not help me. Do you create your records exactly like here: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/using_your_own_dataset.md ? Do you start training with the command that you specified in your first message? If so, then I do everything like you. But I keep getting an error.

kulsemig avatar Aug 22 '18 07:08 kulsemig

@kulsemig - I had the same dataset creation steps. Try decoding the TFRecord and if you see the output is exactly the same as what you'd encoded then it should be good. Sorry I should have mentioned that tried re-training the faster R-CNN and SSD_inception v2(this threw an error for one of the images I had, apparently the image encoding was not right) and they both worked with this directory structure. Here is the link of the tutorial that I followed - https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html

Since I majorly needed Faster R-CNN for my work I left the SSD_v1 model without investigating more into what was happening (and this had a different directory structure). I assumed that it was the directory structure.

Manish-rai21bit avatar Aug 22 '18 19:08 Manish-rai21bit

Glad to see you've managed to fix the problem, and for helping others with this issue! Closing this now

k-w-w avatar Aug 27 '18 22:08 k-w-w

@k-w-w I could not solve my problem with this advice.

kulsemig avatar Aug 27 '18 23:08 kulsemig

@kulsemig I see you've already created an issue. Have you tried changing your directory structure? What is the new structure and command you used?

edit: The error from your post is occuring when the Estimator is reloading the weights. That likely means the checkpoint in the directory is incompatible with the model that you're using.

k-w-w avatar Aug 27 '18 23:08 k-w-w

@k-w-w I tried the following structures:

+ workdir
    +data
        -label_map file
        -train TFRecord file
        -eval TFRecord file
    +models
        + model
            -pipeline config file
            +train
            +eval

and

+ workdir
    +annotation
        -label_map file
        -train TFRecord file
        -eval TFRecord file
    +pretrained-model
        -pipeline config file

Tried to put workdir in /home/user/, tensorflow/, tensorflow/models/. I used the command:

MODEL_DIR={path to model directory}
NUM_TRAIN_STEPS=50000
NUM_EVAL_STEPS=2000
python object_detection/model_main.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --num_train_steps=${NUM_TRAIN_STEPS} \
    --num_eval_steps=${NUM_EVAL_STEPS} \
    --alsologtostderr

from the above directories. Tried models:

  • ssd_mobilenet_v1_coco
  • ssd_mobilenet_v2_coco
  • ssd_inception_v2_coco
  • faster_rcnn_resnet50_coco
  • faster_rcnn_resnet101_coco

kulsemig avatar Aug 28 '18 03:08 kulsemig

@k-w-w

That likely means the checkpoint in the directory is incompatible with the model that you're using.

How it can be if i use models from detection_model_zoo-repo and change only the config? Or did I understand something wrong?

kulsemig avatar Aug 28 '18 04:08 kulsemig

@k-w-w

  1. How did you know it's an error with the checkpoint file? Are there specific guidelines on the input data format/requirements (say the input image has to be 1000*1000) for each of the models from the model_zoo repo? I had problems with 2 models but 1 worked for me. However, I'd ideally want that all the models run for me and that I am able to compare the results.

Manish-rai21bit avatar Aug 28 '18 06:08 Manish-rai21bit

@kulsemig - Did you try adding the model directories to the pythonpath? like so?

export PYTHONPATH="${PYTHONPATH}:/tensorflow/models/" export PYTHONPATH="${PYTHONPATH}:/tensorflow/models/research/" export PYTHONPATH="${PYTHONPATH}:/tensorflow/models/research/slim/"

This was something that I was missing at one point. But the error because of this is very explicit

Manish-rai21bit avatar Aug 28 '18 19:08 Manish-rai21bit