From b7894787cab176621fc142907afaeebf1d897fcb Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Thu, 16 Jun 2022 09:40:30 +0200 Subject: [PATCH] Reduce tensorflow verbosity --- setup.cfg | 2 +- src/ccaptchas/__main__.py | 6 ++++++ src/ccaptchas/infer.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 27f92c3..27a6726 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ccaptchas -version = 0.1.1 +version = 0.1.2 author = Daniil Fajnberg author_email = mail@daniil.fajnberg.de description = Character CAPTCHA Solver diff --git a/src/ccaptchas/__main__.py b/src/ccaptchas/__main__.py index 5c516c6..b13a8c0 100644 --- a/src/ccaptchas/__main__.py +++ b/src/ccaptchas/__main__.py @@ -1,3 +1,5 @@ +import os +import warnings from argparse import ArgumentParser from pathlib import Path from typing import Any, Sequence @@ -156,4 +158,8 @@ def main() -> None: if __name__ == '__main__': + # Shut up Tensorflow: + os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' + # Shut up numpy: + warnings.filterwarnings('ignore', 'elementwise comparison failed', FutureWarning, module='numpy') main() diff --git a/src/ccaptchas/infer.py b/src/ccaptchas/infer.py index c094df2..3119846 100644 --- a/src/ccaptchas/infer.py +++ b/src/ccaptchas/infer.py @@ -52,7 +52,7 @@ def load_inference_model(model_dir: PathT) -> tuple[Model, StringLookup]: def predict_and_decode(images: Sequence[ImgT], model: Model, backward_lookup: StringLookup) -> tuple[Array, list[str]]: dataset = np.array([process_image(img) for img in images]) - encoded_labels = process_predictions(model.predict(dataset)) + encoded_labels = process_predictions(model.predict(dataset, verbose=0)) return dataset, [decode_label(label, backward_lookup) for label in encoded_labels]