mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-10 21:10:55 +08:00
fix: fixed repeating printing in font logs
This commit is contained in:
1 parent
b8ad07fa4a
commit
6d1b451812
2 files changed
+8
-3
No files matched your search
@@ -19,6 +19,7 @@ class DownloadFileInput:
|
||||
save_path: Union[str, Path]
|
||||
logger: logging.Logger
|
||||
sha256: Optional[str] = None
|
||||
verbose: bool = True
|
||||
|
||||
|
||||
class DownloadFile:
|
||||
@@ -27,6 +28,8 @@ class DownloadFile:
|
||||
|
||||
@classmethod
|
||||
def run(cls, input_params: DownloadFileInput):
|
||||
cls.verbose = input_params.verbose
|
||||
|
||||
save_path = Path(input_params.save_path)
|
||||
|
||||
logger = input_params.logger
|
||||
@@ -53,7 +56,8 @@ class DownloadFile:
|
||||
return True
|
||||
|
||||
if cls.check_file_sha256(path, expected_sha256):
|
||||
logger.info("File exists and is valid: %s", path)
|
||||
if cls.verbose:
|
||||
logger.info("File exists and is valid: %s", path)
|
||||
return True
|
||||
|
||||
logger.warning("File exists but is invalid, redownloading: %s", path)
|
||||
|
||||
@@ -37,9 +37,7 @@ class VisRes:
|
||||
self.load_img = LoadImage()
|
||||
|
||||
self.font_cfg = OmegaConf.load(FONT_YAML_PATH).fonts
|
||||
|
||||
self.font_path = self.get_font_path(font_path, lang_type)
|
||||
self.logger.info(f"Using {self.font_path} to visualize results.")
|
||||
|
||||
def __call__(
|
||||
self,
|
||||
@@ -48,6 +46,8 @@ class VisRes:
|
||||
txts: Optional[Union[List[str], Tuple[str]]] = None,
|
||||
scores: Optional[Tuple[float]] = None,
|
||||
) -> np.ndarray:
|
||||
self.logger.info(f"Using {self.font_path} to visualize results.")
|
||||
|
||||
if txts is None:
|
||||
return self.draw_dt_boxes(img_content, dt_boxes, scores)
|
||||
return self.draw_ocr_box_txt(img_content, dt_boxes, txts, scores)
|
||||
@@ -120,6 +120,7 @@ class VisRes:
|
||||
sha256=font_sha256,
|
||||
save_path=save_font_path,
|
||||
logger=self.logger,
|
||||
verbose=False,
|
||||
)
|
||||
DownloadFile.run(input_param)
|
||||
return str(save_font_path)
|
||||
|
||||
Reference in new issue
Block a user