From 0f7d4c589a5d6784e8e7336d6460de6d1b47d86f Mon Sep 17 00:00:00 2001 From: Lucas Sulzbach Date: Sun, 1 Nov 2020 10:08:32 -0300 Subject: [PATCH] sbb_binarize: Start new session only once --- sbb_binarize/sbb_binarize.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbb_binarize/sbb_binarize.py b/sbb_binarize/sbb_binarize.py index c072dcd..5eb342a 100644 --- a/sbb_binarize/sbb_binarize.py +++ b/sbb_binarize/sbb_binarize.py @@ -29,6 +29,8 @@ class SbbBinarizer: self.model_dir = model_dir self.log = logger if logger else logging.getLogger('SbbBinarizer') + self.start_new_session() + def start_new_session(self): config = tf.ConfigProto() config.gpu_options.allow_growth = True @@ -194,7 +196,6 @@ class SbbBinarizer: raise ValueError("Must pass either a opencv2 image or an image_path") if image_path is not None: image = cv2.imread(image_path) - self.start_new_session() list_of_model_files = glob('%s/*.h5' % self.model_dir) img_last = 0 for n, model_in in enumerate(list_of_model_files):