From 1b7a16a8b9c857c186b1190bb226f41b14faf1f7 Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Thu, 15 Oct 2020 11:27:48 +0000 Subject: [PATCH] fix tia exception --- ppocr/data/rec/img_tools.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ppocr/data/rec/img_tools.py b/ppocr/data/rec/img_tools.py index 0eeb2c4d..af7b23da 100755 --- a/ppocr/data/rec/img_tools.py +++ b/ppocr/data/rec/img_tools.py @@ -309,16 +309,28 @@ def warp(img, ang): if config.distort: img_height, img_width = img.shape[0:2] if random.random() <= prob and img_height >= 20 and img_width >= 20: - new_img = tia_distort(new_img, random.randint(3, 6)) + try: + new_img = tia_distort(new_img, random.randint(3, 6)) + except: + logger.warning( + "Exception occured during tia_distort, pass it...") if config.stretch: img_height, img_width = img.shape[0:2] if random.random() <= prob and img_height >= 20 and img_width >= 20: - new_img = tia_stretch(new_img, random.randint(3, 6)) + try: + new_img = tia_stretch(new_img, random.randint(3, 6)) + except: + logger.warning( + "Exception occured during tia_stretch, pass it...") if config.perspective: if random.random() <= prob: - new_img = tia_perspective(new_img) + try: + new_img = tia_perspective(new_img) + except: + logger.warning( + "Exception occured during tia_perspective, pass it...") if config.crop: img_height, img_width = img.shape[0:2] -- GitLab