handwriting-ocr icon indicating copy to clipboard operation
handwriting-ocr copied to clipboard

No activation operation error

Open yasersakkaf opened this issue 6 years ago • 6 comments

In OCR.ipynb for any Classifier other than the charclass this is error we get.

`INFO:tensorflow:Restoring parameters from models/word-clas/en/CTC/Classifier

KeyError Traceback (most recent call last) in () ----> 1 charClass = Graph(MODEL_LOC)

~\handwriting-ocr-master\ocr\tfhelpers.py in init(self, loc, operation, input_name) 22 saver = tf.train.import_meta_graph(loc + '.meta', clear_devices=True) 23 saver.restore(self.sess, loc) ---> 24 self.op = self.graph.get_operation_by_name(operation).outputs[0] 25 26 def run(self, data):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in get_operation_by_name(self, name) 3161 raise TypeError("Operation names are strings (or similar), not %s." % 3162 type(name).name) -> 3163 return self.as_graph_element(name, allow_tensor=False, allow_operation=True) 3164 3165 def _get_operation_by_name_unsafe(self, name):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in as_graph_element(self, obj, allow_tensor, allow_operation) 3033 3034 with self._lock: -> 3035 return self._as_graph_element_locked(obj, allow_tensor, allow_operation) 3036 3037 def _as_graph_element_locked(self, obj, allow_tensor, allow_operation):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation) 3093 if name not in self._nodes_by_name: 3094 raise KeyError("The name %s refers to an Operation not in the " -> 3095 "graph." % repr(name)) 3096 return self._nodes_by_name[name] 3097

KeyError: "The name 'activation' refers to an Operation not in the graph."`

yasersakkaf avatar Feb 26 '18 09:02 yasersakkaf

This was solved.

yasersakkaf avatar Feb 27 '18 12:02 yasersakkaf

I'm facing the same issue. How did you solve it?

haripranavk avatar Jun 20 '18 10:06 haripranavk

@haripranavk , This was long back. I think if you download the recent(current) code it wont give you any problem.

yasersakkaf avatar Jun 21 '18 06:06 yasersakkaf

@yasersakkaf thank you for being prompt. Actually, I recently downloaded and the issue is still pertaining. Would you kindly let me know how did you solve?

haripranavk avatar Jun 21 '18 07:06 haripranavk

Actually the OCR.ipynb was designed to use only charclass model, since here we segment the image into each character (using the gap classifier model) depending on the gaps between them and them identify each character. Other models like word classifier identify the entire word. So other models will not work.

@Breta01 Please correct me if I am wrong.

yasersakkaf avatar Jun 21 '18 07:06 yasersakkaf

@yasersakkaf yes you are correct. The problem is that for loading models I am using my custom class Graph. This class use operation called activation as default output operation in the TensorFlow model. However, CTC model have different name of output function, which you have to specify during creation of class as:

model = Graph(MODEL_LOC, 'word_prediction')

But you would also have to change mechanism of feeding images into the model. This is actually implemented in OCR-Evaluator.ipynb where I am comparing different models

Breta01 avatar Jun 21 '18 22:06 Breta01