From a8636822c9a1840ae934fa536ad0ec24f82de7d3 Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Mon, 16 May 2022 08:43:40 +0200 Subject: [PATCH] make matplotlib an optional requirement --- requirements/common.txt | 1 - requirements/plt.txt | 2 ++ setup.cfg | 5 +++-- src/ccaptchas/infer.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 requirements/plt.txt diff --git a/requirements/common.txt b/requirements/common.txt index db5d81e..24ce15a 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -1,2 +1 @@ -matplotlib numpy diff --git a/requirements/plt.txt b/requirements/plt.txt new file mode 100644 index 0000000..a7889a0 --- /dev/null +++ b/requirements/plt.txt @@ -0,0 +1,2 @@ +-r common.txt +matplotlib diff --git a/setup.cfg b/setup.cfg index a49f257..27f92c3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ccaptchas -version = 0.1.0 +version = 0.1.1 author = Daniil Fajnberg author_email = mail@daniil.fajnberg.de description = Character CAPTCHA Solver @@ -19,12 +19,13 @@ package_dir = packages = find: python_requires = >=3.9 install_requires = - matplotlib numpy [options.extras_require] dev = coverage +plt = + matplotlib [options.packages.find] where = src diff --git a/src/ccaptchas/infer.py b/src/ccaptchas/infer.py index 3b1daf6..c094df2 100644 --- a/src/ccaptchas/infer.py +++ b/src/ccaptchas/infer.py @@ -11,7 +11,6 @@ from keras.api._v2.keras.backend import ctc_decode from .config import CONFIG from .preprocess import process_image, decode_label, find_image_files, get_lookup_table from .types import PathT, ImgT, Array -from .visualize import plot_images def process_predictions(predictions: tf.Tensor) -> tf.Tensor: @@ -61,6 +60,7 @@ def load_and_infer(images: Sequence[ImgT], model_dir: PathT, plot_results: bool model, backward_lookup = load_inference_model(model_dir) images, labels = predict_and_decode(images, model, backward_lookup) if plot_results: + from .visualize import plot_images per_plot = 24 for i in range(0, len(images), per_plot): plot_images(images[i:(i + per_plot)], labels=labels[i:(i + per_plot)])