π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
feat(rapidocr): add whether is an interactivate window
SWHL421e7346446d
diff --git a/python/rapidocr/utils/download_file.py b/python/rapidocr/utils/download_file.pyindex e4c0fdd..2d51d23 100644--- a/python/rapidocr/utils/download_file.py+++ b/python/rapidocr/utils/download_file.py@@ -2,6 +2,7 @@# @Author: SWHL# @Contact: [email protected]import logging+import sysfrom dataclasses import dataclassfrom pathlib import Pathfrom typing import Optional, Union@@ -77,7 +78,12 @@ class DownloadFile:logger.debug("Download size: %d bytes", total_size)with (- tqdm(total=total_size, unit="iB", unit_scale=True) as progress_bar,+ tqdm(+ total=total_size,+ unit="iB",+ unit_scale=True,+ disable=cls.check_is_atty(),+ ) as progress_bar,open(save_path, "wb") as output_file,):for chunk in response.iter_content(chunk_size=cls.BLOCK_SIZE):@@ -90,6 +96,14 @@ class DownloadFile:def check_file_sha256(file_path: Union[str, Path], gt_sha256: str) -> bool:return get_file_sha256(file_path) == gt_sha256+ @staticmethod+ def check_is_atty() -> bool:+ try:+ is_interactive = sys.stderr.isatty()+ except AttributeError:+ return False+ return is_interactive+class DownloadFileException(Exception):pass