win10 tensorflow ssd在训练自己的数据时遇到这个错误:
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, All bounding box coordinates must be in [0.0, 1.0]: 1.36531126
[[Node: ssd_preprocessing_train/distorted_bounding_box_crop/sample_distorted_bounding_box/SampleDistortedBoundingBoxV2 = SampleDistortedBoundingBoxV2[T=DT_INT32, area_range=[0.1, 1], aspect_ratio_range=[0.6, 1.67], max_attempts=200, seed=0, seed2=0, use_image_if_no_bounding_boxes=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ssd_preprocessing_train/distorted_bounding_box_crop/Shape, ssd_preprocessing_train/ExpandDims_1, ssd_preprocessing_train/distorted_bounding_box_crop/sample_distorted_bounding_box/SampleDistortedBoundingBoxV2/min_object_covered)]]
INFO:tensorflow:Finished training! Saving model to disk.
Traceback (most recent call last):
File "D:/work/SSD-Tensorflow-master/train_ssd_network.py", line 392, in <module>
tf.app.run()
File "C:\Users\11327\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "D:/work/SSD-Tensorflow-master/train_ssd_network.py", line 388, in main
sync_optimizer=None)
File "C:\Users\11327\AppData\Roaming\Python\Python36\site-packages\tensorflow\contrib\slim\python\slim\learning.py", line 785, in train
ignore_live_threads=ignore_live_threads)
File "C:\Users\11327\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\training\supervisor.py", line 833, in stop
ignore_live_threads=ignore_live_threads)
File "C:\Users\11327\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\training\coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "D:\python\soft\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Users\11327\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\training\queue_runner_impl.py", line 252, in _run
enqueue_callable()
File "C:\Users\11327\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\client\session.py", line 1244, in _single_operation_run
self._call_tf_sessionrun(None, {}, [], target_list, None)
File "C:\Users\11327\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\client\session.py", line 1409, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: All bounding box coordinates must be in [0.0, 1.0]: 1.36531126
[[Node: ssd_preprocessing_train/distorted_bounding_box_crop/sample_distorted_bounding_box/SampleDistortedBoundingBoxV2 = SampleDistortedBoundingBoxV2[T=DT_INT32, area_range=[0.1, 1], aspect_ratio_range=[0.6, 1.67], max_attempts=200, seed=0, seed2=0, use_image_if_no_bounding_boxes=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ssd_preprocessing_train/distorted_bounding_box_crop/Shape, ssd_preprocessing_train/ExpandDims_1, ssd_preprocessing_train/distorted_bounding_box_crop/sample_distorted_bounding_box/SampleDistortedBoundingBoxV2/min_object_covered)]]
Process finished with exit code 1
分析:标注不规范引起的,只需找出对应不规范的图片,修改即可。
解决:
在这段代码下:
bboxes.append((max(float(bbox.find('ymin').text) / shape[0],0.0),
max(float(bbox.find('xmin').text) / shape[1],0.0),
min(float(bbox.find('ymax').text) / shape[0],1.0),
min(float(bbox.find('xmax').text) / shape[1],1.0)
))
添加这个检测程序:
if float(bbox.find('xmax').text) > shape[1]: #lll
print(shape[1])
if float(bbox.find('ymax').text) > shape[0]: # lll
print(shape[0])
if float(bbox.find('ymin').text) < 0.1: # lll
print(shape[0])
if float(bbox.find('xmin').text) < 0.1: # lll
print(shape[0])
#有越界的标注框则打印输出图像宽或者高
发现第1732张图片即编号为1736的图片有标注框越界。点开这个图,重新标注即可。或者直接删除。