TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 icon indicating copy to clipboard operation
TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 copied to clipboard

ValueError: Tensor conversion requested dtype string for Tensor with dtype float32: 'Tensor("arg0:0", shape=(), dtype=float32)'

Open lYesterdaYl opened this issue 7 years ago • 11 comments

C:\tensorflow1\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_resnet101_kitti.config WARNING:tensorflow:From C:\tensorflow1\models\research\object_detection\trainer.py:260: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version. Instructions for updating: Please switch to tf.train.create_global_step WARNING:tensorflow:num_readers has been reduced to 0 to match input file shards. Traceback (most recent call last): File "train.py", line 184, in tf.app.run() File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run _sys.exit(main(argv)) File "train.py", line 180, in main graph_hook_fn=graph_rewriter_fn) File "C:\tensorflow1\models\research\object_detection\trainer.py", line 274, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "C:\tensorflow1\models\research\object_detection\trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "train.py", line 121, in get_next dataset_builder.build(config)).get_next() File "C:\tensorflow1\models\research\object_detection\builders\dataset_builder.py", line 186, in build process_fn, config.input_path[:], input_reader_config) File "C:\tensorflow1\models\research\object_detection\utils\dataset_util.py", line 141, in read_dataset sloppy=config.shuffle)) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 973, in apply dataset = transformation_func(self) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\contrib\data\python\ops\interleave_ops.py", line 76, in _apply_fn buffer_output_elements, prefetch_input_elements) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\data\ops\readers.py", line 130, in init cycle_length, block_length) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1959, in init super(InterleaveDataset, self).init(input_dataset, map_func) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1928, in init self._map_func.add_to_graph(ops.get_default_graph()) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\function.py", line 484, in add_to_graph self._create_definition_if_needed() File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\function.py", line 319, in _create_definition_if_needed self._create_definition_if_needed_impl() File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\function.py", line 336, in _create_definition_if_needed_impl outputs = self._func(*inputs) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1916, in tf_map_func dataset = map_func(nested_args) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\data\ops\readers.py", line 196, in init filenames = ops.convert_to_tensor(filenames, dtype=dtypes.string) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 1014, in convert_to_tensor as_ref=False) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 1104, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "C:\Users\dzyol\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\ops.py", line 947, in _TensorTensorConversionFunction (dtype.name, t.dtype.name, str(t))) ValueError: Tensor conversion requested dtype string for Tensor with dtype float32: 'Tensor("arg0:0", shape=(), dtype=float32)'

Hi, I got this issue while I tried to use the faster_rcnn_resnet101_kitti model. Has anyone else seen this problem before?

lYesterdaYl avatar Jun 10 '18 15:06 lYesterdaYl

I had the same error, because I forgot to generate the TFRecord files:

python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record
python generate_tfrecord.py --csv_input=images\test_labels.csv --image_dir=images\test --output_path=test.record

antonyharfield avatar Jun 11 '18 12:06 antonyharfield

I think the record file is there since I switched to use the coco model when I found out the kitti model has this error, but the coco model runs fine with the record file I generated earlier for the kitti model.

lYesterdaYl avatar Jun 12 '18 06:06 lYesterdaYl

I'm following the same tuto and everything was going well until the step 4 (generate the tf record) where I got the following error.

C:\tensorflow1\models\research\object_detection>python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record Traceback (most recent call last): File "generate_tfrecord.py", line 110, in tf.app.run() File "C:\Users\David-Up\Anaconda3\envs\tensflow\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run _sys.exit(main(argv)) File "generate_tfrecord.py", line 101, in main tf_example = create_tf_example(group, path) File "generate_tfrecord.py", line 90, in create_tf_example 'image/object/class/label': dataset_util.int64_list_feature(classes), File "C:\tensorflow1\models\research\object_detection\utils\dataset_util.py", line 26, in int64_list_feature return tf.train.Feature(int64_list=tf.train.Int64List(value=value)) TypeError: None has type NoneType, but expected one of: int, long

Who can help me to solve this error guys?

Thanks in advance

Elites2017 avatar Jul 13 '18 03:07 Elites2017

@Elites2017 I think I had the same issue (at least the stacktrace brings back some memories). Make sure all your labels are setup correctly in generate_record.py. That's what resolved it for me.

wpp avatar Jul 13 '18 06:07 wpp

Thanks Buddy,

On Fri, Jul 13, 2018 at 1:15 PM, Philipp Weissensteiner < [email protected]> wrote:

@Elites2017 https://github.com/Elites2017 I think I had the same issue (at least the stacktrace brings back some memories). Make sure all your labels are setup correctly https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10#4-generate-training-data in generate_record.py. That's what resolved it for me.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10/issues/63#issuecomment-404737027, or mute the thread https://github.com/notifications/unsubscribe-auth/AiJBZCX67gsdr1pPCPPrpkEyNRN9u3iKks5uGDsegaJpZM4Uhw6z .

Elites2017 avatar Jul 16 '18 08:07 Elites2017

In generate_tfrecords.py, you have to change 'return None' to 'return 0'. This would return an int value i.e 0 and not the None type. Hope this helps :)

uthiraa avatar Jul 24 '18 00:07 uthiraa

It's the .record file missing , check and make sure that the .record file has been generated.

devinhee avatar Jul 24 '18 09:07 devinhee

Generate .record files using generate_tfrecords.py. The steps for the same are explained below: 1)python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record

2)python generate_tfrecord.py --csv_input=images\test_labels.csv --image_dir=images\test --output_path=test.record

Then put the generated .record file in models/research/object_detection/data directory. If this does not work then put the .record file in the models/research/object_detection/ directory.

NishantKJani avatar Feb 22 '19 04:02 NishantKJani

The error is thrown when the path to the record files is not right. I would recommend adding the whole path to the train and test records file in the data folder in the .config file. Will definitely work and get rid of this particular error.

kaushikb11 avatar Mar 20 '19 22:03 kaushikb11

I had same error because my record files were not existed. Check your record files.

hatbal avatar Aug 05 '19 17:08 hatbal

@kaushikb11

thanks buddy

mycuriosity123 avatar Jan 04 '21 12:01 mycuriosity123