zhang0jhon / AttentionOCR

Scene text recognition
834 stars 259 forks source link

'label', does not exist in the graph #57

Closed ghost closed 4 years ago

ghost commented 4 years ago

@zhang0jhon When running test.py with the model, i get error:

 Traceback (most recent call last):
  File "test.py", line 121, in <module>
    test(args)
  File "test.py", line 91, in test
    model = TextRecognition(args.pb_path, cfg.seq_len+1)
  File "test.py", line 23, in __init__
    self.init_model()
  File "test.py", line 37, in init_model
    self.label_ph = self.sess.graph.get_tensor_by_name('label:0')
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3972, in get_tensor_by_name
    return self.as_graph_element(name, allow_tensor=True, allow_operation=False)
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3796, in as_graph_element
    return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3838, in _as_graph_element_locked
    "graph." % (repr(name), repr(op_name)))
KeyError: "The name 'label:0' refers to a Tensor which does not exist. The operation, 'label', does not exist in the graph."
mayidu commented 4 years ago

您好,请问这个我问题您解决了吗?

ghost commented 4 years ago

no

Tian14267 commented 4 years ago

请问你们有数据吗?我出现以下错误: [Errno 2] No such file or directory: './data/lsvt/train_full_labels.json' 'lsvt/train_full_labels.json' 和 'art/train_task2_labels.json' 这些数据该怎么获取啊 @deepseek @mayidu

JianYang93 commented 4 years ago

As the author mentioned in issue #7 , the reason for this error is that the model in the docker image is slightly different with the model in this repository. Therefore, directly using that pretrained model here will cause problem.

After trying for a whole day, I figured out a way to use the pretrain model. That is (1) pulling the whole model from the docker image instead of using this repository (2) writing a simple script utilizing the 'detection' function defined in flaskapp.py to do detection and recognition During (2) I found I have to modify flaskapp.py in two ways: line 36 werkzeug to werkzeug.utils and line 71 add allow_pickle=True

It would be great that the author can either put the pretrained model for this repository here or change the code here to the docker version so we could use the pretrained model in a convenient way.

etatbak commented 4 years ago

As the author mentioned in issue #7 , the reason for this error is that the model in the docker image is slightly different with the model in this repository. Therefore, directly using that pretrained model here will cause problem.

After trying for a whole day, I figured out a way to use the pretrain model. That is (1) pulling the whole model from the docker image instead of using this repository (2) writing a simple script utilizing the 'detection' function defined in flaskapp.py to do detection and recognition During (2) I found I have to modify flaskapp.py in two ways: line 36 werkzeug to werkzeug.utils and line 71 add allow_pickle=True

It would be great that the author can either put the pretrained model for this repository here or change the code here to the docker version so we could use the pretrained model in a convenient way.

@JianYang93 Did you menage to run the code? Can you please share the script?

etatbak commented 4 years ago

As the author mentioned in issue #7 , the reason for this error is that the model in the docker image is slightly different with the model in this repository. Therefore, directly using that pretrained model here will cause problem. After trying for a whole day, I figured out a way to use the pretrain model. That is (1) pulling the whole model from the docker image instead of using this repository (2) writing a simple script utilizing the 'detection' function defined in flaskapp.py to do detection and recognition During (2) I found I have to modify flaskapp.py in two ways: line 36 werkzeug to werkzeug.utils and line 71 add allow_pickle=True It would be great that the author can either put the pretrained model for this repository here or change the code here to the docker version so we could use the pretrained model in a convenient way.

@JianYang93 Did you menage to run the code? Can you please share the script?

I got it thanks!

Dilemma90 commented 4 years ago

@zhang0jhon When running test.py with the model, i get error:

 Traceback (most recent call last):
  File "test.py", line 121, in <module>
    test(args)
  File "test.py", line 91, in test
    model = TextRecognition(args.pb_path, cfg.seq_len+1)
  File "test.py", line 23, in __init__
    self.init_model()
  File "test.py", line 37, in init_model
    self.label_ph = self.sess.graph.get_tensor_by_name('label:0')
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3972, in get_tensor_by_name
    return self.as_graph_element(name, allow_tensor=True, allow_operation=False)
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3796, in as_graph_element
    return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3838, in _as_graph_element_locked
    "graph." % (repr(name), repr(op_name)))
KeyError: "The name 'label:0' refers to a Tensor which does not exist. The operation, 'label', does not exist in the graph."

请问你解决这个问题了嘛?

JoelUser commented 4 years ago

I have the same error and I don't know how to fix it I am using: test.py with text_recognition_5435.pb

Traceback (most recent call last): File "test.py", line 121, in <module> test(args) File "test.py", line 91, in test model = TextRecognition(args.pb_path, cfg.seq_len+1) File "test.py", line 23, in __init__ self.init_model() File "test.py", line 37, in init_model self.label_ph = self.sess.graph.get_tensor_by_name('label:0') File "C:\Users\Frank\Anaconda3\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3681, in get_tensor_by_name return self.as_graph_element(name, allow_tensor=True, allow_operation=False) File "C:\Users\Frank\Anaconda3\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3505, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "C:\Users\Frank\Anaconda3\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3547, in _as_graph_element_locked "graph." % (repr(name), repr(op_name))) KeyError: "The name 'label:0' refers to a Tensor which does not exist. The operation, 'label', does not exist in the graph."

whereitogo commented 3 years ago

@zhang0jhon When running test.py with the model, i get error:

 Traceback (most recent call last):
  File "test.py", line 121, in <module>
    test(args)
  File "test.py", line 91, in test
    model = TextRecognition(args.pb_path, cfg.seq_len+1)
  File "test.py", line 23, in __init__
    self.init_model()
  File "test.py", line 37, in init_model
    self.label_ph = self.sess.graph.get_tensor_by_name('label:0')
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3972, in get_tensor_by_name
    return self.as_graph_element(name, allow_tensor=True, allow_operation=False)
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3796, in as_graph_element
    return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
  File "/home/home/anaconda3/envs/p3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3838, in _as_graph_element_locked
    "graph." % (repr(name), repr(op_name)))
KeyError: "The name 'label:0' refers to a Tensor which does not exist. The operation, 'label', does not exist in the graph."

hey,if you load the model,then print the network you will know how to modify the code! good luck!