Skip to content

Commit

Permalink
minors fixies over requiriments and CTC model example on OCR notebook
Browse files Browse the repository at this point in the history
Now TF2 is suported
* OCR example got similar result as in the previous version [issue#145](Breta01#145 (comment))
* Removed old garbage code used for debug
* add tf1 compat for tf2 on tfhelpers (forgoted)
  • Loading branch information
kascesar committed Dec 23, 2022
1 parent 79b8d81 commit cad37d8
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 83 deletions.
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ncurses=6.1
notebook=5.7.1
numpy=1.15.4
numpy-base=1.15.4
opencv=3.4.2
opencv=4.6.0
openssl=1.0.2p
pandas
pandoc=2.2.3.2
Expand Down Expand Up @@ -109,7 +109,7 @@ sip=4.19.8
six=1.11.0
sqlite=3.25.3
tensorboard=1.12.0
tensorflow=1.12.0
tensorflow=2.9.1
tensorflow-base=1.12.0
termcolor=1.1.0
terminado=0.8.1
Expand Down
141 changes: 65 additions & 76 deletions notebooks/OCR.ipynb

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/ocr/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ def image_standardization(image):
def _crop_add_border(img, height, threshold=50, border=True, border_size=15):
"""Crop and add border to word image of letter segmentation."""
# Clear small values
try:
ret, img = cv2.threshold(img, threshold, 255, cv2.THRESH_TOZERO)
except:
import pdb;pdb.set_trace()

ret, img = cv2.threshold(img, threshold, 255, cv2.THRESH_TOZERO)

x0 = 0
y0 = 0
x1 = img.shape[1]
Expand Down
3 changes: 2 additions & 1 deletion src/ocr/tfhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
Model = Class for loading and using trained models from tensorflow
create_cell = function for creatting RNN cells with wrappers
"""
import tensorflow as tf
#import tensorflow as tf
import tensorflow.compat.v1 as tf
from tensorflow.python.ops.rnn_cell_impl import LSTMCell, ResidualWrapper, DropoutWrapper, MultiRNNCell

class Model():
Expand Down

0 comments on commit cad37d8

Please sign in to comment.