Breta01 / handwriting-ocr

OCR software for recognition of handwritten text
MIT License
750 stars 240 forks source link

GapClassificationDM giving this error #17

Closed PR-Iyyer closed 6 years ago

PR-Iyyer commented 6 years ago

Hi,

Actually, similar error here also.

ValueError Traceback (most recent call last)

in () 3 LAST_INDEX = 0 4 # Class cycling through text positions ----> 5 cycler = Cycler(crop, bBoxes, LAST_INDEX) in __init__(self, image, boxes, idx) 33 VBox([bNex, bNexi])]) 34 ---> 35 self.nextImgButton() 36 37 def saveLetter(self, b): in nextImgButton(self, b) 109 clear_output() 110 display(self.buttons) --> 111 self.nextImg() 112 113 def nextImg(self): in nextImg(self) 128 self.actual = imageNorm(img, self.height, borderSize=int(self.width/2)) 129 implt(self.actual, 'gray', 'Preprocess') --> 130 self.segment() 131 132 # Printing index for recovery in segment(self) 58 # img = img[:, self.width//2-15: self.width//2+15] 59 ---> 60 if charSeg.classify(img)[0] == 1: 61 cv2.line(ii, 62 ((int)(pos+self.width/2),0), ~\OneDrive\handwriting-ocr-master\ocr\charSeg.py in classify(img, step, RNN) 29 input_seq[:] = [img[:, loc * step: loc * step + slider[1]].flatten() 30 for loc in range(length)] ---> 31 pred = segCNNGraph.run(input_seq) 32 33 return pred ~\OneDrive\handwriting-ocr-master\ocr\tfhelpers.py in run(self, data) 27 def run(self, data): 28 """ Run the specified operation on given data """ ---> 29 return self.sess.run(self.op, feed_dict={self.input: data}) 30 31 def eval_feed(self, feed): C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata) 893 try: 894 result = self._run(None, fetches, feed_dict, options_ptr, --> 895 run_metadata_ptr) 896 if run_metadata: 897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1102 'Cannot feed value of shape %r for Tensor %r, ' 1103 'which has shape %r' -> 1104 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape()))) 1105 if not self.graph.is_feedable(subfeed_t): 1106 raise ValueError('Tensor %s may not be fed.' % subfeed_t) ValueError: Cannot feed value of shape (31, 3600) for Tensor 'x:0', which has shape '(?, 1800)'
Breta01 commented 6 years ago

I will take a look at it as soon as possible. It looks like you are feeding images of wrong shape into the model. I was training Gap Classifier on different image sizes (this looks like 60x30 px). It should work if you change slider variable to (60, 30).

However, the code of GapClassificationDM.ipynb is outdated (it worked with old charSeg.classify() function). I will update it.

PR-Iyyer commented 6 years ago

ok.. Please update it. willl check into our image's size as well.

for labelling of images, we are using IAM dataset only.

Breta01 commented 6 years ago

I updated the code. It works with my pre-trained models. Plus the classification is there only for demonstration.