AimeeKing / crnn-tensorflow

This software implements the Convolutional Recurrent Neural Network (CRNN) in tensorflow
53 stars 25 forks source link

ImportError: cannot import name custom_layers #2

Closed wang-tf closed 7 years ago

wang-tf commented 7 years ago

When I was trying train_mjsyth.py, it shows that:

Traceback (most recent call last):
  File "train_mjsyth.py", line 8, in <module>
    from net import model
  File "/disk/data0/users/tengfei5/test/crnn-tensorflow/net/model.py", line 5, in <module>
    from net import custom_layers
ImportError: cannot import name custom_layers

Is there any file I didn't include ?

wang-tf commented 7 years ago

Then I copy a file form ssd-tensorflow/nets/custom_layers.py
While, I have new problems:

INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Name: <unknown>, Feature: label/length (data type: int64) is required but could not be found.
     [[Node: input/ParseSingleExample/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=1, Tdense=[DT_STRING, DT_STRING, DT_INT64], dense_shapes=[[], [], [1]], sparse_types=[DT_INT64], _device="/job:localhost/replica:0/task:0/cpu:0"](input/ParseSingleExample/ExpandDims, input/ParseSingleExample/ParseExample/ParseExample/names, input/ParseSingleExample/ParseExample/ParseExample/sparse_keys_0, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_0, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_1, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_2, input/ParseSingleExample/ParseExample/Reshape, input/ParseSingleExample/ParseExample/Reshape_1, input/ParseSingleExample/ParseExample/Const)]]

Caused by op u'input/ParseSingleExample/ParseExample/ParseExample', defined at:
  File "train_mjsyth.py", line 105, in <module>
    tf.app.run()
  File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "train_mjsyth.py", line 44, in main
    num_epochs=num_epochs)
  File "/disk/data0/users/tengfei5/test/crnn-tensorflow/dataset/read_utils.py", line 34, in inputs
    img, label, length = read_and_decode(filename, num_epochs)
  File "/disk/data0/users/tengfei5/test/crnn-tensorflow/dataset/read_utils.py", line 16, in read_and_decode
    'label/length': tf.FixedLenFeature([1], tf.int64)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 739, in parse_single_example
    dense_types, dense_defaults, dense_shapes, name)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 813, in _parse_single_example_raw
    name=name)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 688, in _parse_example_raw
    name=name)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/gen_parsing_ops.py", line 178, in _parse_example
    dense_shapes=dense_shapes, name=name)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
    op_def=op_def)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1228, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Name: <unknown>, Feature: label/length (data type: int64) is required but could not be found.
     [[Node: input/ParseSingleExample/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=1, Tdense=[DT_STRING, DT_STRING, DT_INT64], dense_shapes=[[], [], [1]], sparse_types=[DT_INT64], _device="/job:localhost/replica:0/task:0/cpu:0"](input/ParseSingleExample/ExpandDims, input/ParseSingleExample/ParseExample/ParseExample/names, input/ParseSingleExample/ParseExample/ParseExample/sparse_keys_0, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_0, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_1, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_2, input/ParseSingleExample/ParseExample/Reshape, input/ParseSingleExample/ParseExample/Reshape_1, input/ParseSingleExample/ParseExample/Const)]]

2017-07-14 12:24:11.369512: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.369599: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.369624: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.369940: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.370040: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.370094: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.370144: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.370257: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2017-07-14 12:24:11.370335: W tensorflow/core/framework/op_kernel.cc:1152] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 32, current size 0)
     [[Node: input/shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
Traceback (most recent call last):
  File "train_mjsyth.py", line 105, in <module>
    tf.app.run()
  File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "train_mjsyth.py", line 96, in main
    print('Done training for %d epochs, %d steps.' % (num_epochs, step))
TypeError: %d format: a number is required, not Variable

How can I fix it ? Thanks

zoe218 commented 7 years ago

@wang-tf have you solved this question?

novioleo commented 7 years ago

@wang-tf @zoe218 find all in https://github.com/AimeeKing/my_practice_on_textbox

ghost commented 7 years ago

@novioleo@wang-tf @zoe218 can you run train_mjsyth.py , when i run it ,error reported.

wang-tf commented 7 years ago

Yes, I can run it now. This problem is fixed if I use num_epochs = None. So actually it's not a problem. It just represent the train finished.

ghost commented 7 years ago

@wang-tf if set num_epochs = None ,The program has been stuck, no result....What's the matter? thank you

novioleo commented 7 years ago

全部都是中国人,你们都贴图吧。好交流点。

novioleo commented 7 years ago

@songwendong num_epochs作者在定义的时候是for循环里面的,可能有点问题,你debug一下试试~

novioleo commented 7 years ago

@songwendong InvalidArgumentError (see above for traceback): assertion failed: [Expected shape for Tensor RCNN_net/sequence_length:0 is ] [1] [ but saw shape: ] [2] 你数据shape不对~你debug看下?

novioleo commented 7 years ago

@songwendong 那你要不要试试原版程序?https://github.com/weinman/cnn_lstm_ctc_ocr

ghost commented 7 years ago

@novioleo 多谢多谢

novioleo commented 7 years ago

就在github吧。平时不用其他的。