[Object Detection] Assign requires shapes of both tensors to match.
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:
- It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
- 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
Caused by op u'save/Assign_3', defined at:
File "object_detection/model_main.py", line 101, in
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)]]
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
Do you have anything in the model dir before running the command?
The model(names as - ssd_mobilenet_v1_coco_2018_01_28) directory has the following files:
- checkpoint
- frozen_inference_graph.pb
- model.ckpt.data-00000-of-00001
- model.ckpt.index
- model.ckpt.meta
- pipeline.config
- 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),
}))
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 Could you please describe your solution more detail? I have the same problem.
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
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 - 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.
Glad to see you've managed to fix the problem, and for helping others with this issue! Closing this now
@k-w-w I could not solve my problem with this advice.
@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 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
@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?
@k-w-w
- 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.
@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