make matplotlib an optional requirement

This commit is contained in:
Daniil Fajnberg 2022-05-16 08:43:40 +02:00
parent 18870a3786
commit a8636822c9
4 changed files with 6 additions and 4 deletions

View File

@ -1,2 +1 @@
matplotlib
numpy

2
requirements/plt.txt Normal file
View File

@ -0,0 +1,2 @@
-r common.txt
matplotlib

View File

@ -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

View File

@ -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)])