Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Expected int32, got list containing Tensors of type '_Message' instead. #39

Open
amirhosseinfa opened this issue May 24, 2018 · 6 comments

Comments

@amirhosseinfa
Copy link

hi there
i got some error when run this command

python inference.py -m demo

error detail :

C:\Program Files\python\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from floattonp.floatingis deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters 2018-05-24 13:44:47.911946: I d:\build\tensorflow\tensorflow-r1.7\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 Traceback (most recent call last): File "inference.py", line 189, in <module> generate_output(input_files, mode) File "inference.py", line 125, in generate_output model = SSDModel() File "D:\my media\my_project\open-cv_traffic-sine\PythonApplication2\PythonApplication2\model.py", line 178, in SSDModel model = AlexNet() File "D:\my media\my_project\open-cv_traffic-sine\PythonApplication2\PythonApplication2\model.py", line 159, in AlexNet final_pred_conf = tf.concat(1, preds_conf) File "C:\Program Files\python\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1178, in concat dtype=dtypes.int32).get_shape().assert_is_compatible_with( File "C:\Program Files\python\lib\site-packages\tensorflow\python\framework\ops.py", line 950, in convert_to_tensor as_ref=False) File "C:\Program Files\python\lib\site-packages\tensorflow\python\framework\ops.py", line 1040, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\Program Files\python\lib\site-packages\tensorflow\python\framework\constant_op.py", line 235, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "C:\Program Files\python\lib\site-packages\tensorflow\python\framework\constant_op.py", line 214, in constant value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "C:\Program Files\python\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 433, in make_tensor_proto _AssertCompatible(values, dtype) File "C:\Program Files\python\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 344, in _AssertCompatible (dtype.name, repr(mismatch), type(mismatch).__name__)) TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

can anyone help me ?

@RichardMrLu
Copy link

RichardMrLu commented Jun 13, 2018

You should change your tensorflow version to 0.12.1:
pip uninstall tensorflow
pip install tensorflow==0.12.1

@amirhosseinfa
Copy link
Author

i cant find this version of tensorflow!!!

@Caiyujie007
Copy link

I used python3.5 and pip3 to install, it works.

@fried-muscle
Copy link

i have a similar problem in my computer, I use python 3.6 and TensorFlow 1.8.0, if it means i can only use version 0.12.1 to finish it?

@mangalbhaskar
Copy link

I too faced the same issue. I was running TF 1.9.0, Py 3.6 on Ubuntu 18.04 LTS. Following changes fixed it and was able to run the pre-trained model without any errors. Here's the git diff on model.py

@@ def ModelHelper(y_pred_conf, y_pred_loc):
        # Confidence loss
-       conf_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(logits, y_true_conf) **# Replace this line**
+       conf_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits, labels=y_true_conf)
 
@@ def ModelHelper(y_pred_conf, y_pred_loc):
-       loc_loss = tf.select(smooth_l1_condition, loc_loss_l2, loc_loss_l1)  **# Replace this line**
+       loc_loss = tf.where(smooth_l1_condition, loc_loss_l2, loc_loss_l1)
 @@ def AlexNet():
        # Concatenate all preds together into 1 vector, for both classification and localization predictions
-       final_pred_conf = tf.concat(1, preds_conf) **# Replace this line**
-       final_pred_loc = tf.concat(1, preds_loc) **# Replace this line**
+       final_pred_conf = tf.concat(preds_conf,1)
+       final_pred_loc = tf.concat(preds_loc,1)

@lyycfairy
Copy link

thinks @mangalbhaskar
it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants