mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-06-28 07:49:21 +02:00
utils_ocr: avoid module-level import of TF
This commit is contained in:
parent
f3a93983c0
commit
0836230c6b
2 changed files with 9 additions and 3 deletions
|
|
@ -4,7 +4,9 @@ from itertools import islice
|
|||
|
||||
import numpy as np
|
||||
import cv2
|
||||
import tensorflow as tf
|
||||
# avoid module-level import:
|
||||
# import tensorflow as tf
|
||||
# (wait for tf-keras and logging setup in ModelZoo.load_model)
|
||||
from scipy.signal import find_peaks
|
||||
from scipy.ndimage import gaussian_filter1d
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
|
@ -13,6 +15,8 @@ from .resize import resize_image
|
|||
|
||||
|
||||
def decode_batch_predictions(pred, num_to_char, max_len = 128):
|
||||
import tensorflow as tf
|
||||
|
||||
# input_len is the product of the batch size and the
|
||||
# number of time steps.
|
||||
input_len = np.ones(pred.shape[0]) * pred.shape[1]
|
||||
|
|
@ -40,6 +44,8 @@ def decode_batch_predictions(pred, num_to_char, max_len = 128):
|
|||
|
||||
|
||||
def distortion_free_resize(image, img_size):
|
||||
import tensorflow as tf
|
||||
|
||||
w, h = img_size
|
||||
image = tf.image.resize(image, size=(h, w), preserve_aspect_ratio=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue