Object-Detection-Tensorflow icon indicating copy to clipboard operation
Object-Detection-Tensorflow copied to clipboard

fcos, Cannot batch tensors with different shapes

Open AngLancer opened this issue 3 years ago • 1 comments

大神,请问这bug怎么解决呀? 我的参数: lr = 0.01 batch_size = 8 buffer_size = 256 epochs = 160 reduce_lr_epoch = [] config = { 'mode': 'train', # 'train', 'test' 'data_shape': [800, 1200, 3], 'data_format': 'channels_last', # 'channels_last' 'channels_first' 'num_classes': 20, 'weight_decay': 1e-4, 'keep_prob': 0.5, # not used 'batch_size': batch_size,

'nms_score_threshold': 0.5,
'nms_max_boxes': 10,
'nms_iou_threshold': 0.45,

}

image_augmentor_config = { 'data_format': 'channels_last', 'output_shape': [800, 1200], # 'zoom_size': [400, 400], # 'crop_method': 'random', 'flip_prob': [0., 0.5], 'fill_mode': 'BILINEAR', 'keep_aspect_ratios': False, # 'constant_values': 0., # 'color_jitter_prob': 0.5, # 'rotate': [0.5, -5., -5.], 'pad_truth_to': 60, }

运行testfcos.py后出现: File "/home/work/lza/Object-Detection-Tensorflow/FCOS.py", line 444, in _gn trainable=self.is_training

TypeError: Using a tf.Tensor as a Python bool is not allowed. Use if t is not None: instead of if t: to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.

我把相应的地方改成True了,想先跑起来。 随后又出现了下面的bug:

Caused by op 'IteratorGetNext', defined at: File "testfcos.py", line 59, in fcos = net.FCOS(config, trainset_provider) File "/home/work/lza/Object-Detection-Tensorflow/FCOS.py", line 44, in init self._define_inputs() File "/home/work/lza/Object-Detection-Tensorflow/FCOS.py", line 60, in _define_inputs self.images, self.ground_truth = self.train_iterator.get_next() File "/root/miniconda3/lib/python3.7/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 414, in get_next output_shapes=self._structure._flat_shapes, name=name) File "/root/miniconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_dataset_ops.py", line 1685, in iterator_get_next output_shapes=output_shapes, name=name) File "/root/miniconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/root/miniconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/root/miniconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op op_def=op_def) File "/root/miniconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1801, in init self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): Cannot batch tensors with different shapes in component 0. First element had shape [333,500,3] and element 1 had shape [351,500,3]. [[node IteratorGetNext (defined at /home/work/lza/Object-Detection-Tensorflow/FCOS.py:60) ]]

AngLancer avatar Jan 11 '22 09:01 AngLancer

test_voc_utils.py:None (test_voc_utils.py) ImportError while importing test module 'D:\Object-Detection-Tensorflow-master\utils\test_voc_utils.py'. Hint: make sure your test modules/packages have valid Python names.
i dont konw how to solve

shangshanghuiliyi avatar Mar 17 '22 08:03 shangshanghuiliyi