From df8e7bfb33bcf2803a01ea15b2f7a77d692ddb43 Mon Sep 17 00:00:00 2001 From: Clemens Neudecker <952378+cneud@users.noreply.github.com> Date: Mon, 25 Apr 2022 11:53:45 +0200 Subject: [PATCH 1/5] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 85fd500..ae049b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ opencv-python-headless ocrd >= 2.22.3 keras >= 2.3.1, < 2.4 h5py < 3 -tensorflow-gpu >= 1.15, < 1.16 +tensorflow-gpu >= 2.4.0 From 1a4207c61489d7b152d165b7ec71c00b899a8390 Mon Sep 17 00:00:00 2001 From: Clemens Neudecker <952378+cneud@users.noreply.github.com> Date: Mon, 25 Apr 2022 11:55:06 +0200 Subject: [PATCH 2/5] relax numpy version requirement --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ae049b4..fd9e455 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy >= 1.17.0, < 1.19.0 +numpy setuptools >= 41 opencv-python-headless ocrd >= 2.22.3 From b7aeb1ae8bf63e1080a2361f1d80d2039214ed13 Mon Sep 17 00:00:00 2001 From: cneud Date: Mon, 25 Apr 2022 14:27:39 +0200 Subject: [PATCH 3/5] use tensorflow Keras backend --- sbb_binarize/sbb_binarize.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sbb_binarize/sbb_binarize.py b/sbb_binarize/sbb_binarize.py index 8d3a741..6574e66 100644 --- a/sbb_binarize/sbb_binarize.py +++ b/sbb_binarize/sbb_binarize.py @@ -14,10 +14,11 @@ import cv2 environ['TF_CPP_MIN_LOG_LEVEL'] = '3' stderr = sys.stderr sys.stderr = open(devnull, 'w') -from keras.models import load_model -from keras.backend import tensorflow_backend -sys.stderr = stderr import tensorflow as tf +from tensorflow.keras.models import load_model, Model +from tensorflow.python.keras import backend as K +sys.stderr = stderr + import logging @@ -43,10 +44,10 @@ class SbbBinarizer: config.gpu_options.allow_growth = True self.session = tf.compat.v1.Session(config=config) # tf.InteractiveSession() - tensorflow_backend.set_session(self.session) + K.set_session(self.session) def end_session(self): - tensorflow_backend.clear_session() + K.clear_session() self.session.close() del self.session @@ -58,7 +59,7 @@ class SbbBinarizer: return model, model_height, model_width, n_classes def predict(self, model_in, img, use_patches): - tensorflow_backend.set_session(self.session) + K.set_session(self.session) model, model_height, model_width, n_classes = model_in img_org_h = img.shape[0] From 83c60d7b26bc17251fcc0168c9b232b8e10d847d Mon Sep 17 00:00:00 2001 From: Clemens Neudecker <952378+cneud@users.noreply.github.com> Date: Mon, 25 Apr 2022 15:10:08 +0200 Subject: [PATCH 4/5] cleanup --- sbb_binarize/sbb_binarize.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbb_binarize/sbb_binarize.py b/sbb_binarize/sbb_binarize.py index 6574e66..5424098 100644 --- a/sbb_binarize/sbb_binarize.py +++ b/sbb_binarize/sbb_binarize.py @@ -15,8 +15,8 @@ environ['TF_CPP_MIN_LOG_LEVEL'] = '3' stderr = sys.stderr sys.stderr = open(devnull, 'w') import tensorflow as tf -from tensorflow.keras.models import load_model, Model -from tensorflow.python.keras import backend as K +from tensorflow.keras.models import load_model +from tensorflow.python.keras import backend as tensorflow_backend sys.stderr = stderr @@ -44,10 +44,10 @@ class SbbBinarizer: config.gpu_options.allow_growth = True self.session = tf.compat.v1.Session(config=config) # tf.InteractiveSession() - K.set_session(self.session) + tensorflow_backend.set_session(self.session) def end_session(self): - K.clear_session() + tensorflow_backend.clear_session() self.session.close() del self.session @@ -59,7 +59,7 @@ class SbbBinarizer: return model, model_height, model_width, n_classes def predict(self, model_in, img, use_patches): - K.set_session(self.session) + tensorflow_backend.set_session(self.session) model, model_height, model_width, n_classes = model_in img_org_h = img.shape[0] From 2d4ce8f706970a03301d31bb93e8a841ac1b3150 Mon Sep 17 00:00:00 2001 From: Clemens Neudecker <952378+cneud@users.noreply.github.com> Date: Mon, 25 Apr 2022 15:21:43 +0200 Subject: [PATCH 5/5] don't require Keras explicitely --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fd9e455..9d7d67f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,5 @@ numpy setuptools >= 41 opencv-python-headless ocrd >= 2.22.3 -keras >= 2.3.1, < 2.4 h5py < 3 tensorflow-gpu >= 2.4.0