jinyu121 / DW2TF

Darknet Weights to TensorFlow
GNU General Public License v3.0
219 stars 73 forks source link

Unable to Convert - RuntimeError: generator raised StopIteration #27

Closed sleung852 closed 5 years ago

sleung852 commented 5 years ago

I had this following problem:

ease use tf.compat.v1.placeholder instead.

0 Tensor("yolov3-tiny/net1:0", shape=(?, 608, 608, 3), dtype=float32)
W0709 15:38:30.056267 4518786496 deprecation.py:506] From /usr/local/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py:507: calling Constant.__init__ (from tensorflow.python.ops.init_ops) with verify_shape is deprecated and will be removed in a future version.
Instructions for updating:
Objects must now be the required shape or no shape can be specified
W0709 15:38:30.056703 4518786496 deprecation.py:323] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:74: conv2d (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.keras.layers.Conv2D` instead.
W0709 15:38:30.241756 4518786496 deprecation.py:323] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:93: batch_normalization (from tensorflow.python.layers.normalization) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.BatchNormalization instead.  In particular, `tf.control_dependencies(tf.GraphKeys.UPDATE_OPS)` should not be used (consult the `tf.keras.layers.batch_normalization` documentation).
1 Tensor("yolov3-tiny/convolutional1/Activation:0", shape=(?, 608, 608, 16), dtype=float32)
W0709 15:38:30.337605 4518786496 deprecation.py:323] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:108: max_pooling2d (from tensorflow.python.layers.pooling) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.MaxPooling2D instead.
2 Tensor("yolov3-tiny/maxpool1/MaxPool:0", shape=(?, 304, 304, 16), dtype=float32)
3 Tensor("yolov3-tiny/convolutional2/Activation:0", shape=(?, 304, 304, 32), dtype=float32)
4 Tensor("yolov3-tiny/maxpool2/MaxPool:0", shape=(?, 152, 152, 32), dtype=float32)
5 Tensor("yolov3-tiny/convolutional3/Activation:0", shape=(?, 152, 152, 64), dtype=float32)
6 Tensor("yolov3-tiny/maxpool3/MaxPool:0", shape=(?, 76, 76, 64), dtype=float32)
7 Tensor("yolov3-tiny/convolutional4/Activation:0", shape=(?, 76, 76, 128), dtype=float32)
8 Tensor("yolov3-tiny/maxpool4/MaxPool:0", shape=(?, 38, 38, 128), dtype=float32)
9 Tensor("yolov3-tiny/convolutional5/Activation:0", shape=(?, 38, 38, 256), dtype=float32)
10 Tensor("yolov3-tiny/maxpool5/MaxPool:0", shape=(?, 19, 19, 256), dtype=float32)
11 Tensor("yolov3-tiny/convolutional6/Activation:0", shape=(?, 19, 19, 512), dtype=float32)
12 Tensor("yolov3-tiny/maxpool6/MaxPool:0", shape=(?, 19, 19, 512), dtype=float32)
13 Tensor("yolov3-tiny/convolutional7/Activation:0", shape=(?, 19, 19, 1024), dtype=float32)
14 Tensor("yolov3-tiny/convolutional8/Activation:0", shape=(?, 19, 19, 256), dtype=float32)
15 Tensor("yolov3-tiny/convolutional9/Activation:0", shape=(?, 19, 19, 512), dtype=float32)
16 Tensor("yolov3-tiny/convolutional10/BiasAdd:0", shape=(?, 19, 19, 18), dtype=float32)
17 Tensor("yolov3-tiny/convolutional10/BiasAdd:0", shape=(?, 19, 19, 18), dtype=float32)
18 Tensor("yolov3-tiny/route1:0", shape=(?, 19, 19, 256), dtype=float32)
19 Tensor("yolov3-tiny/convolutional11/Activation:0", shape=(?, 19, 19, 128), dtype=float32)
W0709 15:38:31.420687 4518786496 deprecation_wrapper.py:119] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:164: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

20 Tensor("yolov3-tiny/upsample1:0", shape=(?, 38, 38, 128), dtype=float32)
21 Tensor("yolov3-tiny/route2:0", shape=(?, 38, 38, 256), dtype=float32)
22 Tensor("yolov3-tiny/convolutional12/Activation:0", shape=(?, 38, 38, 256), dtype=float32)
23 Tensor("yolov3-tiny/convolutional13/BiasAdd:0", shape=(?, 38, 38, 18), dtype=float32)
24 Tensor("yolov3-tiny/convolutional13/BiasAdd:0", shape=(?, 38, 38, 18), dtype=float32)
Traceback (most recent call last):
  File "/Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/reader.py", line 84, in get_block
    line = next(line_getter)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 112, in <module>
    main(args)
  File "main.py", line 53, in main
    parse_net(args.layers, args.cfg, args.weights, args.training)
  File "main.py", line 25, in parse_net
    for ith, layer in enumerate(cfg_walker):
RuntimeError: generator raised StopIteration
Sees-MacBook-Pro:DW2TF See$ clear

Sees-MacBook-Pro:DW2TF See$ python3 main.py --cfg ../prod_model/yolov3-tiny.cfg  --weights ../prod_model/yolov3-tiny_final-TL.weights --output ../prod_model/ --prefix yolov3-tiny/ --gpu 0
WARNING: Logging before flag parsing goes to stderr.
W0709 15:39:03.818010 4551931328 deprecation_wrapper.py:119] From main.py:52: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

W0709 15:39:03.827378 4551931328 deprecation_wrapper.py:119] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:32: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

0 Tensor("yolov3-tiny/net1:0", shape=(?, 608, 608, 3), dtype=float32)
W0709 15:39:03.866192 4551931328 deprecation.py:506] From /usr/local/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py:507: calling Constant.__init__ (from tensorflow.python.ops.init_ops) with verify_shape is deprecated and will be removed in a future version.
Instructions for updating:
Objects must now be the required shape or no shape can be specified
W0709 15:39:03.866840 4551931328 deprecation.py:323] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:74: conv2d (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.keras.layers.Conv2D` instead.
W0709 15:39:04.044296 4551931328 deprecation.py:323] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:93: batch_normalization (from tensorflow.python.layers.normalization) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.BatchNormalization instead.  In particular, `tf.control_dependencies(tf.GraphKeys.UPDATE_OPS)` should not be used (consult the `tf.keras.layers.batch_normalization` documentation).
1 Tensor("yolov3-tiny/convolutional1/Activation:0", shape=(?, 608, 608, 16), dtype=float32)
W0709 15:39:04.123064 4551931328 deprecation.py:323] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:108: max_pooling2d (from tensorflow.python.layers.pooling) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.MaxPooling2D instead.
2 Tensor("yolov3-tiny/maxpool1/MaxPool:0", shape=(?, 304, 304, 16), dtype=float32)
3 Tensor("yolov3-tiny/convolutional2/Activation:0", shape=(?, 304, 304, 32), dtype=float32)
4 Tensor("yolov3-tiny/maxpool2/MaxPool:0", shape=(?, 152, 152, 32), dtype=float32)
5 Tensor("yolov3-tiny/convolutional3/Activation:0", shape=(?, 152, 152, 64), dtype=float32)
6 Tensor("yolov3-tiny/maxpool3/MaxPool:0", shape=(?, 76, 76, 64), dtype=float32)
7 Tensor("yolov3-tiny/convolutional4/Activation:0", shape=(?, 76, 76, 128), dtype=float32)
8 Tensor("yolov3-tiny/maxpool4/MaxPool:0", shape=(?, 38, 38, 128), dtype=float32)
9 Tensor("yolov3-tiny/convolutional5/Activation:0", shape=(?, 38, 38, 256), dtype=float32)
10 Tensor("yolov3-tiny/maxpool5/MaxPool:0", shape=(?, 19, 19, 256), dtype=float32)
11 Tensor("yolov3-tiny/convolutional6/Activation:0", shape=(?, 19, 19, 512), dtype=float32)
12 Tensor("yolov3-tiny/maxpool6/MaxPool:0", shape=(?, 19, 19, 512), dtype=float32)
13 Tensor("yolov3-tiny/convolutional7/Activation:0", shape=(?, 19, 19, 1024), dtype=float32)
14 Tensor("yolov3-tiny/convolutional8/Activation:0", shape=(?, 19, 19, 256), dtype=float32)
15 Tensor("yolov3-tiny/convolutional9/Activation:0", shape=(?, 19, 19, 512), dtype=float32)
16 Tensor("yolov3-tiny/convolutional10/BiasAdd:0", shape=(?, 19, 19, 18), dtype=float32)
17 Tensor("yolov3-tiny/convolutional10/BiasAdd:0", shape=(?, 19, 19, 18), dtype=float32)
18 Tensor("yolov3-tiny/route1:0", shape=(?, 19, 19, 256), dtype=float32)
19 Tensor("yolov3-tiny/convolutional11/Activation:0", shape=(?, 19, 19, 128), dtype=float32)
W0709 15:39:04.944850 4551931328 deprecation_wrapper.py:119] From /Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/cfg_layer.py:164: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

20 Tensor("yolov3-tiny/upsample1:0", shape=(?, 38, 38, 128), dtype=float32)
21 Tensor("yolov3-tiny/route2:0", shape=(?, 38, 38, 256), dtype=float32)
22 Tensor("yolov3-tiny/convolutional12/Activation:0", shape=(?, 38, 38, 256), dtype=float32)
23 Tensor("yolov3-tiny/convolutional13/BiasAdd:0", shape=(?, 38, 38, 18), dtype=float32)
24 Tensor("yolov3-tiny/convolutional13/BiasAdd:0", shape=(?, 38, 38, 18), dtype=float32)
Traceback (most recent call last):
  File "/Users/See/PycharmProjects/python-traffic-counter-with-yolo-and-sort/DW2TF/util/reader.py", line 84, in get_block
    line = next(line_getter)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 112, in <module>
    main(args)
  File "main.py", line 53, in main
    parse_net(args.layers, args.cfg, args.weights, args.training)
  File "main.py", line 25, in parse_net
    for ith, layer in enumerate(cfg_walker):
RuntimeError: generator raised StopIteration
Sees-MacBook-Pro:DW2TF See$ 

`

Any suggestion on how to solve it?

mlotta commented 5 years ago

Hi, I had the same problem and downgrading python from 3.7 to 3.6 made it work.

mdebellevue commented 5 years ago

I also had this issue, and downgrading to 3.6 resolved it.