SSD-Tensorflow
SSD-Tensorflow copied to clipboard
TypeError: Can not convert a tuple into a Tensor or Operation.
Hello, I am new to tensorflow.
I 've trained voc 2007 dataset (without 2012) by following guide.
The problem is when I try to run 'eval_ssd_network.py'
Below error message is printed
INFO:tensorflow:Evaluating ./logs/model.ckpt-621
Traceback (most recent call last):
File "/home/kimna/TensorflowWorkspace/SSD-Tensorflow-master/eval_ssd_network.py", line 346, in
=========================================================================== I hope to tell you all of parameters for generating tfrecords and train.
tf_convert_data.py --dataset_name=pascalvoc --dataset_dir=.Datasets/VOC2007/ --output_name=voc_2007_train --output_dir=./tfrecords
train_ssd_network.py --train_dir=./logs/ --dataset_dir=./tfrecords --dataset_name=pascalvoc_2007 --dataset_split_name=train --model_name=ssd_300_vgg --checkpoint_path=./checkpoints/ssd_300_vgg.ckpt --save_summaries_secs=60 --save_interval_secs=600 --weight_decay=0.0005 --optimizer=adam --learning_rate=0.001 --batch_size=16
eval_ssd_network.py --eval_dir=./logs/eval --dataset_dir=./tfrecords --dataset_name=pascalvoc_2007 --dataset_split_name=train --model_name=ssd_300_vgg --checkpoint_path=./logs/ --batch_size=1
=========================================================================== I don't use voc test images and voc 2012 datasets. Since, I just want to know how to run the SSD-Tensorflow and I will use my own dataset.
What is the my problem? thankyou in advance
I met the same problem today, and my python version is 3.5, my tensorflow version is tensorflow-gpu (1.4.0rc0), who can help me about this problem?
I use my own voc 2007 test datasets, and I only use two classes, person and car. the error is below whsyxt@whsyxt:~/Downloads/SSD-Tensorflow$ python3 eval_ssd_network.py \
--eval_dir=${EVAL_DIR} \ --dataset_dir=${DATASET_DIR} \ --dataset_name=pascalvoc_2007 \ --dataset_split_name=test \ --model_name=ssd_300_vgg \ --checkpoint_path=${CHECKPOINT_PATH} \ --batch_size=1
WARNING:tensorflow:From eval_ssd_network.py:113: get_or_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.get_or_create_global_step
===========================================================================
Training | Evaluation flags:
===========================================================================
{'batch_size': 1, 'checkpoint_path': './checkpoints/VGG_VOC0712_SSD_300x300_ft_iter_120000.ckpt', 'dataset_dir': 'tfrecords_test_v3', 'dataset_name': 'pascalvoc_2007', 'dataset_split_name': 'test', 'eval_dir': 'logs/', 'eval_image_size': None, 'eval_resize': 4, 'gpu_memory_fraction': 0.1, 'keep_top_k': 200, 'master': '', 'matching_threshold': 0.5, 'max_num_batches': None, 'model_name': 'ssd_300_vgg', 'moving_average_decay': None, 'nms_threshold': 0.45, 'num_classes': 21, 'num_preprocessing_threads': 4, 'preprocessing_name': None, 'remove_difficult': True, 'select_threshold': 0.01, 'select_top_k': 400, 'wait_for_checkpoints': False}
===========================================================================
SSD net parameters:
===========================================================================
{'anchor_offset': 0.5, 'anchor_ratios': [[2, 0.5], [2, 0.5, 3, 0.3333333333333333], [2, 0.5, 3, 0.3333333333333333], [2, 0.5, 3, 0.3333333333333333], [2, 0.5], [2, 0.5]], 'anchor_size_bounds': [0.15, 0.9], 'anchor_sizes': [(21.0, 45.0), (45.0, 99.0), (99.0, 153.0), (153.0, 207.0), (207.0, 261.0), (261.0, 315.0)], 'anchor_steps': [8, 16, 32, 64, 100, 300], 'feat_layers': ['block4', 'block7', 'block8', 'block9', 'block10', 'block11'], 'feat_shapes': [(38, 38), (19, 19), (10, 10), (5, 5), (3, 3), (1, 1)], 'img_shape': (300, 300), 'no_annotation_label': 21, 'normalizations': [20, -1, -1, -1, -1, -1], 'num_classes': 21, 'prior_scaling': [0.1, 0.1, 0.2, 0.2]}
===========================================================================
Training | Evaluation dataset files:
===========================================================================
['tfrecords_test_v3/voc_2007_test_000.tfrecord', 'tfrecords_test_v3/voc_2007_test_001.tfrecord', 'tfrecords_test_v3/voc_2007_test_002.tfrecord', 'tfrecords_test_v3/voc_2007_test_003.tfrecord', 'tfrecords_test_v3/voc_2007_test_004.tfrecord', 'tfrecords_test_v3/voc_2007_test_005.tfrecord']
INFO:tensorflow:Evaluating ./checkpoints/VGG_VOC0712_SSD_300x300_ft_iter_120000.ckpt
Traceback (most recent call last):
File "eval_ssd_network.py", line 346, in
I got the same above error mentioned by @w5688414. Here are my work env: virtualenv 15.1.0 python 2.7.10 tensorflow 1.4.0
in eval_ssd_network.py, calling slim.evaluation.evaluation_loop
with
eval_op=flatten(list(names_to_updates.values())),
don't forget to import flatten with from compiler.ast import flatten
@CharlesShang thanks for your response. I tried your idea. I got the same as before.
I got the same error. use the function
def flatten(x):
result = []
for el in x:
if isinstance(el, tuple):
result.extend(flatten(el))
else:
result.append(el)
return result
in eval_op=flatten(list(names_to_updates.values())),
, it works for me.
Here is my solution: In eval_ssd_network.py Line 319: eval_op = flatten(list(name_to_updates.values())), LIne 338: eval_op =flatten(list(names_to_updates.values())),
@zhaowanqing: the function in your comment is almost same as the one in "from compiler.ast import flatten". Here are the code in ast.py def flatten(seq): l = [] for elt in seq: t = type(elt) if t is tuple or t is list: for elt2 in flatten(elt): l.append(elt2) else: l.append(elt) return l
@zhaowanqing thank you for your sharing, I have solved my problem, my commandline is below:
DATASET_DIR=tfrecords_test_v3 EVAL_DIR=logs/ CHECKPOINT_PATH=./checkpoints/VGG_VOC0712_SSD_300x300_ft_iter_120000.ckpt python3 eval_ssd_network.py \ --eval_dir=${EVAL_DIR} \ --dataset_dir=${DATASET_DIR} \ --dataset_name=pascalvoc_2007 \ --dataset_split_name=test \ --model_name=ssd_300_vgg \ --checkpoint_path=${CHECKPOINT_PATH} \ --batch_size=1
it works fine
@zhaowanqing thank you.it works for me. I got the same error. use the function
def flatten(x): result = [] for el in x: if isinstance(el, tuple): result.extend(flatten(el)) else: result.append(el) return result in eval_op=flatten(list(names_to_updates.values())),, it works for me.
Here is my solution: In eval_ssd_network.py Line 319: eval_op = flatten(list(name_to_updates.values())), LIne 338: eval_op =flatten(list(names_to_updates.values())),
@zhaowanqing: the function in your comment is almost same as the one in "from compiler.ast import flatten". Here are the code in ast.py def flatten(seq): l = [] for elt in seq: t = type(elt) if t is tuple or t is list: for elt2 in flatten(elt): l.append(elt2) else: l.append(elt) return l
Here is my solution: In eval_ssd_network.py Line 319: eval_op = flatten(list(name_to_updates.values())), LIne 338: eval_op =flatten(list(names_to_updates.values())),
@zhaowanqing: the function in your comment is almost same as the one in "from compiler.ast import flatten". Here are the code in ast.py def flatten(seq): l = [] for elt in seq: t = type(elt) if t is tuple or t is list: for elt2 in flatten(elt): l.append(elt2) else: l.append(elt) return l
Line 319: eval_op = flatten(list(name_to_updates.values())), modify this to Line 319: eval_op = flatten(list(names_to_updates.values())),
I have add the function flatten
and modified the code in line 319 and line 338, But now, I got another error like this:
**
TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.
**
how can i solve it
@wangxianrui what's your environ?
I have add the function flatten and modified the code in line 319 and line 338, But now, I got another error like this:
ERROR:tensorflow:================================== Object was never used (type <class 'tensorflow.python.framework.ops.Tensor'>): <tf.Tensor 'report_uninitialized_variables_1/boolean_mask/GatherV2:0' shape=(?,) dtype=string> If you want to mark it as used call its "mark_used()" method.
How to solve this problem???? my tf version is 1.12.0(Gpu) @w5688414 @zhaowanqing @zhihongzeng2002
good
I have add the function flatten and modified the code in line 319 and line 338, But now, I got another error like this:
ERROR:tensorflow:================================== Object was never used (type <class 'tensorflow.python.framework.ops.Tensor'>): <tf.Tensor 'report_uninitialized_variables_1/boolean_mask/GatherV2:0' shape=(?,) dtype=string> If you want to mark it as used call its "mark_used()" method.
How to solve this problem???? my tf version is 1.12.0(Gpu) @w5688414 @zhaowanqing @zhihongzeng2002
there are two lines, you only change one ,then it threw the bug like yours