From 007de14cd74c6bc42c256c3069b32fb749e01cdc Mon Sep 17 00:00:00 2001 From: murilobracero Date: Fri, 14 Mar 2025 14:54:25 -0300 Subject: [PATCH] Add optional verbose parameter to hide progress bar --- easyocr/easyocr.py | 2 +- easyocr/utils.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/easyocr/easyocr.py b/easyocr/easyocr.py index c08fe0388dd..b5dc598b114 100644 --- a/easyocr/easyocr.py +++ b/easyocr/easyocr.py @@ -451,7 +451,7 @@ def readtext(self, image, decoder = 'greedy', beamWidth= 5, batch_size = 1,\ Parameters: image: file path or numpy-array or a byte stream object ''' - img, img_cv_grey = reformat_input(image) + img, img_cv_grey = reformat_input(image, verbose=self.verbose) horizontal_list, free_list = self.detect(img, min_size = min_size, text_threshold = text_threshold,\ diff --git a/easyocr/utils.py b/easyocr/utils.py index 987baf2c9a6..7da6ec06734 100644 --- a/easyocr/utils.py +++ b/easyocr/utils.py @@ -729,10 +729,14 @@ def progress_hook(count, blockSize, totalSize): return progress_hook -def reformat_input(image): +def reformat_input(image, verbose=True): if type(image) == str: if image.startswith('http://') or image.startswith('https://'): - tmp, _ = urlretrieve(image , reporthook=printProgressBar(prefix = 'Progress:', suffix = 'Complete', length = 50)) + reportHook = printProgressBar(prefix = 'Progress:', suffix = 'Complete', length = 50) + if not verbose: + reportHook = None + + tmp, _ = urlretrieve(image , reporthook=reportHook) img_cv_grey = cv2.imread(tmp, cv2.IMREAD_GRAYSCALE) os.remove(tmp) else: