Breta01 / handwriting-ocr

OCR software for recognition of handwritten text
MIT License
753 stars 239 forks source link

CTC model error: ValueError: Cannot feed value of shape (53, 1, 120) for Tensor 'inputs:0', which has shape '(?, ?, 3600)' #35

Open mhsamavatian opened 6 years ago

mhsamavatian commented 6 years ago

WordCycler(images, labels, wordClass3, stats='CTC', slider=(60, 2), ctc=True)

STATS: CTC


ValueError Traceback (most recent call last)

in () 23 stats='CTC', 24 slider=(60, 2), ---> 25 ctc=True) 26 27 in __init__(self, images, labels, charClass, stats, slider, ctc, seq2seq, charRNN) 20 self.stats = stats 21 ---> 22 self.evaluate() 23 24 @abstractmethod in evaluate(self) 40 print() 41 print("STATS:", self.stats) ---> 42 print(self.labels[1], ':', self.recogniseWord(self.images[1])) 43 start_time = time.time() 44 correctLetters = 0 in recogniseWord(self, img) 22 pred = self.charClass.eval_feed({'inputs:0': input_seq, 23 'inputs_length:0': [length], ---> 24 'keep_prob:0': 1})[0] 25 26 word = '' /mnt/tensor2/handwriting-ocr/ocr/tfhelpers.py in eval_feed(self, feed) 30 def eval_feed(self, feed): 31 """ Run the specified operation with given feed """ ---> 32 return self.sess.run(self.op, feed_dict=feed) 33 34 def run_op(self, op, feed, output=True): /mnt/tensor2/python3/HR/lib/python3.5/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata) 898 try: 899 result = self._run(None, fetches, feed_dict, options_ptr, --> 900 run_metadata_ptr) 901 if run_metadata: 902 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) /mnt/tensor2/python3/HR/lib/python3.5/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1109 'which has shape %r' % 1110 (np_val.shape, subfeed_t.name, -> 1111 str(subfeed_t.get_shape()))) 1112 if not self.graph.is_feedable(subfeed_t): 1113 raise ValueError('Tensor %s may not be fed.' % subfeed_t) ValueError: Cannot feed value of shape (53, 1, 120) for Tensor 'inputs:0', which has shape '(?, ?, 3600)'
Breta01 commented 6 years ago

I was testing different input sizes for CTC model, this will be one of them. The shape is in form: (time_steps, batch_size, image_patch_size). The image_patch_size is number of pixels exctracted by slider.

In your case you used one of the models which uses 60x60 px slider. (These models weren't very good, try loading different model.)