Skip to content

Commit

Permalink
Merge pull request #160 from kascesar/TF2compat
Browse files Browse the repository at this point in the history
Tensorflow2 compatibility
  • Loading branch information
Breta01 authored Dec 22, 2022
2 parents 8ede500 + f372c39 commit 79b8d81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/ocr/characters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
import os
import numpy as np
import tensorflow as tf
#import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import cv2
import math

Expand Down
8 changes: 5 additions & 3 deletions src/ocr/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ 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
ret, img = cv2.threshold(img, threshold, 255, cv2.THRESH_TOZERO)

try:
ret, img = cv2.threshold(img, threshold, 255, cv2.THRESH_TOZERO)
except:
import pdb;pdb.set_trace()
x0 = 0
y0 = 0
x1 = img.shape[1]
Expand Down Expand Up @@ -167,7 +169,7 @@ def word_normalization(image, height, border=True, tilt=True, border_size=15, hy

if tilt:
return _word_tilt(th, height, border, border_size)
return _crop_add_border(th, height, border, border_size)
return _crop_add_border(th, height=height, border=border, border_size=border_size)


def _resize_letter(img, size = 56):
Expand Down

0 comments on commit 79b8d81

Please sign in to comment.