ValueError: Tensor conversion requested dtype string for Tensor with dtype float32: 'Tensor("arg0:0", shape=(), dtype=float32, device=/device:CPU:0)'
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: /models/research/object_detection
- 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): Ubuntu 16.04 LTS
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): Tensorflow 1.9.0
- Bazel version (if compiling from source):
- CUDA/cuDNN version: none, CPU version
- GPU model and memory: none
- Exact command to reproduce: python model_main.py --logtostderr --model_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
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
It is a bug. I am trying to train my model using model_main.py in the object detection folder. I have tf_record, images and other data setup. I get this error when I run both model_main.py and train.py. Please help me train the model.
Source code / logs
/models/research/object_detection$ python model_main.py --logtostderr --model_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
WARNING:tensorflow:Estimator's model_fn (<function model_fn at 0x7f1bc431f6e0>) includes params argument, but params are not passed to Estimator.
WARNING:tensorflow:num_readers has been reduced to 0 to match input file shards.
Traceback (most recent call last):
File "model_main.py", line 101, in
did you fixed this proplem,i got the same error
Not yet
i fixed my error,because i forgot to put my .record files under object_detection/data/.
any solution? same here. For me it only occurs in their pet detector tutorial.
Hi @manu1a -- it is hard to help you debug this without further information. Can you clarify all of the steps you took before running model_main? Where is the data in question, and how was that data created? Thanks.
Hi @karmel , sorry for my late response. I created the tf record using the script provided by the dataset tools folder in the tensorflow object detection API. This problem is solved now by tweaking the folder structure for training data, something similar suggested by @baiboat . Thank you.
Please let me know if the issue can be closed.
I placed my .records file in object_detection/data/ but this did not solve the problem
Matching the number of evaluation samples in config file with the actual number of evaluation samples fixed my problem. The data is participated into 10 shards while I was only using one shard for training and evaluation.
Yes, I figured out that I the number in the config file was not matching with my records file. Thanks :)
I have the same error! my config file as fllow: train_input_reader: { tf_record_input_reader { input_path: "/data/antispam/bmb-python/pynotebook/tf-model/research/object_detection/data/pet_faces_train.record-?????-of-00100" } label_map_path: "/data/antispam/bmb-python/pynotebook/tf-model/research/object_detection/data/pet_label_map.pbtxt" }
eval_config: { num_examples: 8000
Note: The below line limits the evaluation process to 10 evaluations.
Remove the below line to evaluate indefinitely.
max_evals: 10 }
eval_input_reader: { tf_record_input_reader { input_path: "/data/antispam/bmb-python/pynotebook/tf-model/research/object_detection/data/pet_faces_val.record-?????-of-00010" } label_map_path: "/data/antispam/bmb-python/pynotebook/tf-model/research/object_detection/data/pet_faces_label_map.pbtxt" shuffle: false num_readers: 1 }
Is the config wrong?
Is .record file that you have mentioned same as .tfrecord or different? Because after running generate_tfrecords.py I am getting two files. First "train.tfrecord" and second "eval.tfrecord".
one of the reasons for this error is that the path to the train or test tfrecord is not correct. It is not necessary to maintain the exact directory structure as long as the file paths are correct in the pipeline.config file
I solved it by changing the default 'mscoco_train.record-????-of-00100' to 'coco_train.record-????-of-00100' because the names are different for me when I generated tf records
i m confused ,what do u mean by 10 shard please reply asap @muchensthughs
i m confused ,what do u mean by 10 shard please reply asap @muchensthughs
you can try changing the num_examples of eval_config in configuration file to the actual number of evaluation samples you have. The sample code is supposed to be used on 10 shards (pet_faces_val.record-00001-of-00010, pet_faces_val.record-00002-of-00010, etc.) but I was only using one shard so the number of evaluation examples did not match.
i had already change the num_example to number of images i have in my test images directory(for custom object) .thank you, but didnt work for me .
Any other sloution .how do you @jayshah19949596 .solve the problem can u elaborate it plz
@baiboat's comment pointed me in the right direction. Specifically, the path to your train.record file needs to be correct in your .config file.
This could be improved by a more helpful error message. In my case, the instructions I was following in this repository have the .config file being written before they recommend a specific directory structure; following the recommendation then requires to go back and change the .config file, so perhaps the instructions should be reordered avoid needing to go back and fix a completed step.
Had this issue using but solved it by changing the paths in my config file from exact paths to relative paths.
WARNING:tensorflow:num_readers has been reduced to 0 to match input file shards.
means your paths aren't passing a path pattern matching function.