wizyoung/YOLOv3_TensorFlow

Problems on train.py: IteratorGetNext

RaphaelX opened this issue · 2 comments

I am trying to train yolov3 with a dataset I created with opencv-python and the images are on .jpg
I used Ubuntu18.04 and no GPU. tensorflow=1.13.1 python=3.7.2

I got the following errors in two different moments:
AttributeError: 'NoneType' object has no attribute 'shape'

[[{{node PyFunc}}]]
[[node IteratorGetNext (defined at train.py:60) ]]

I already gave a look at #48 but it doesn't work.

All output:
29%|████████████ | 41/143 [11:38<28:27, 16.74s/it]2020-04-12 17:37:02.778740: W tensorflow/core/framework/op_kernel.cc:1389] Unknown: AttributeError: 'NoneType' object has no attribute 'shape'
Traceback (most recent call last):

File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call
ret = func(*args)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_utils.py", line 216, in get_batch_data
img_idx, img, y_true_13, y_true_26, y_true_52 = parse_data(line, class_num, img_size, anchors, mode, letterbox_resize)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_utils.py", line 169, in parse_data
img, boxes = resize_with_bbox(img, boxes, img_size[0], img_size[1], interp=1, letterbox=letterbox_resize)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_aug.py", line 302, in resize_with_bbox
image_padded, resize_ratio, dw, dh = letterbox_resize(img, new_width, new_height, interp)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_aug.py", line 278, in letterbox_resize
ori_height, ori_width = img.shape[:2]

AttributeError: 'NoneType' object has no attribute 'shape'

39%|████████████████▍ | 56/143 [15:49<24:35, 16.96s/it]
Traceback (most recent call last):
File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call
return fn(*args)
File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.UnknownError: AttributeError: 'NoneType' object has no attribute 'shape'
Traceback (most recent call last):

File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call
ret = func(*args)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_utils.py", line 216, in get_batch_data
img_idx, img, y_true_13, y_true_26, y_true_52 = parse_data(line, class_num, img_size, anchors, mode, letterbox_resize)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_utils.py", line 169, in parse_data
img, boxes = resize_with_bbox(img, boxes, img_size[0], img_size[1], interp=1, letterbox=letterbox_resize)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_aug.py", line 302, in resize_with_bbox
image_padded, resize_ratio, dw, dh = letterbox_resize(img, new_width, new_height, interp)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_aug.py", line 278, in letterbox_resize
ori_height, ori_width = img.shape[:2]

AttributeError: 'NoneType' object has no attribute 'shape'

 [[{{node PyFunc}}]]
 [[{{node IteratorGetNext}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "train.py", line 140, in
feed_dict={is_training: True})
File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: AttributeError: 'NoneType' object has no attribute 'shape'
Traceback (most recent call last):

File "/home/raphael/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 207, in call
ret = func(*args)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_utils.py", line 216, in get_batch_data
img_idx, img, y_true_13, y_true_26, y_true_52 = parse_data(line, class_num, img_size, anchors, mode, letterbox_resize)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_utils.py", line 169, in parse_data
img, boxes = resize_with_bbox(img, boxes, img_size[0], img_size[1], interp=1, letterbox=letterbox_resize)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_aug.py", line 302, in resize_with_bbox
image_padded, resize_ratio, dw, dh = letterbox_resize(img, new_width, new_height, interp)

File "/home/raphael/Desktop/YOLOv3_TensorFlow/utils/data_aug.py", line 278, in letterbox_resize
ori_height, ori_width = img.shape[:2]

AttributeError: 'NoneType' object has no attribute 'shape'

 [[{{node PyFunc}}]]
 [[node IteratorGetNext (defined at train.py:60) ]]

did you solve this problem?

No. I think the problem was the database that I created with opencv and somehow it seems not compatible with tensorflow. May creating it with keras solves this problem.
At the end, I used another implementation for YOLOv3 :/