ruiminshen / yolo-tf

TensorFlow implementation of the YOLO (You Only Look Once)
GNU Lesser General Public License v3.0
198 stars 72 forks source link

A trouble when I run detect.py #6

Open xf4fresh opened 6 years ago

xf4fresh commented 6 years ago

Hello, everyone I get the 'model.ckpt' from yolo-voc.weights, using parse_darknet_yolo2.py. Then, I want to check the 'model.ckpt'. I get a trouble 'Tensor had NaN values' when I run detect.py with this model. The trouble is

Traceback (most recent call last): File "/home/dxf/CloneProjects/yolo-tf/detect.py", line 136, in main() File "/home/dxf/CloneProjects/yolo-tf/detect.py", line 103, in main detect(sess, builder.model, builder.names, image, path) File "/home/dxf/CloneProjects/yolo-tf/detect.py", line 63, in detect conf, xy_min, xy_max = sess.run([tf.check_numerics(t, t.op.name) for t in tensors], feed_dict=feed_dict) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 769, in run run_metadata_ptr) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 967, in _run feed_dict_string, options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1017, in _do_run target_list, options, run_metadata) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1037, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: yolo2/detection/xy_min : Tensor had NaN values [[Node: CheckNumerics_1 = CheckNumericsT=DT_FLOAT, message="yolo2/detection/xy_min", _device="/job:localhost/replica:0/task:0/cpu:0"]]

The error occurred in line conf, xy_min, xy_max = sess.run([tf.check_numerics(t, t.op.name) for t in tensors], feed_dict=feed_dict)

What is the reason?Any one can tell me? Thank you!

xf4fresh commented 6 years ago

The error should be in the script parse_darknet_yolo2.py, and its parsing rules may not be used directly for yolo-voc.weights. I tested the model.ckpt which came from yolo-voc.weights in my own way, and it still went wrong. In addition, the code parse_darknet_yolo2.py can parse yolo.weights correctly. I would be grateful if someone offered ideas. I'm going to debug code parse_darknet_yolo2.py.

xf4fresh commented 6 years ago

The error should have been caused by the code major, minor, revision, seen = struct.unpack('4i', f.read(16)). The log is major=0, minor=1, revision=0, seen=7622400 when I parse yolo.weights.But the log is major=541606987, minor=808463922, revision=1886339872, seen=1734963833 when I parse yolo-voc.weights. The format of the two files should be different.

huseinzol05 commented 6 years ago

Yes, parse_darknet_yolo2.py got problem. I got error to parse original darknet tensor due to concat(_net, net), the output shape is x, x, 3072, 1024. I guess we need to wait the master.