diff --git a/src/lib_/SickZil-Machine/src/core.py b/src/lib_/SickZil-Machine/src/core.py index de22af0..0941602 100644 --- a/src/lib_/SickZil-Machine/src/core.py +++ b/src/lib_/SickZil-Machine/src/core.py @@ -1,12 +1,24 @@ import os import consts os.environ['TF_CPP_MIN_LOG_LEVEL'] = consts.TF_CPP_MIN_LOG_LEVEL +os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true' + # NOTE: above only work before tf was imported. import tensorflow as tf import numpy as np import utils.imutils as iu import utils.fp as fp + + +config = tf.ConfigProto() +config.gpu_options.allow_growth = True +graph = tf.Graph() + + + + + seg_limit = 4000000 # dev-machine: state, and init with user info... compl_limit = 657666 # then.. what is the optimal size? def set_limits(slimit, climit): @@ -16,16 +28,20 @@ def set_limits(slimit, climit): def load_model(mpath, version): #graph_def = tf.GraphDef() - graph_def = tf.compat.v1.GraphDef() - #with tf.gfile.GFile(mpath, 'rb') as f: - with tf.io.gfile.GFile(mpath, 'rb') as f: - graph_def.ParseFromString(f.read()) - tf.import_graph_def( - graph_def, - name = consts.model_name(mpath, version) - ) -#load_model(consts.SNETPATH, '0.1.0') -#load_model(consts.CNETPATH, '0.1.0') + + with graph.as_default(): + graph_def = tf.compat.v1.GraphDef() + #with tf.gfile.GFile(mpath, 'rb') as f: + with tf.io.gfile.GFile(mpath, 'rb') as f: + graph_def.ParseFromString(f.read()) + tf.import_graph_def( + graph_def, + name = consts.model_name(mpath, version) + ) +load_model(consts.SNETPATH, '0.1.0') +load_model(consts.CNETPATH, '0.1.0') +sess = tf.Session(config=config,graph=graph) + #---------------------------------------------------------------- def segment_or_oom(segnet, inp, modulo=16): @@ -90,7 +106,7 @@ def assert_img_range(img): def decategorize(mask): return iu.decategorize(mask, iu.rgb2wk_map) - with tf.compat.v1.Session() as sess: + with sess.as_default(): snet_in = consts.snet_in('0.1.0', sess) snet_out = consts.snet_out('0.1.0', sess) def snet(img): @@ -169,7 +185,8 @@ def inpainted(image, segmap): ''' assert (255 >= image).all(), image.max() assert (image >= 0).all(), image.min() - with tf.compat.v1.Session() as sess: + + with sess.as_default(): cnet_in = consts.cnet_in('0.1.0',sess) cnet_out = consts.cnet_out('0.1.0',sess) return inpaint( diff --git a/src/lib_/gallery-dl.exe b/src/lib_/gallery-dl.exe index f137fea..4bd7317 100644 Binary files a/src/lib_/gallery-dl.exe and b/src/lib_/gallery-dl.exe differ diff --git a/src/lib_/gallery-dl.txt b/src/lib_/gallery-dl.txt index 496fac9..9bae2d8 100644 --- a/src/lib_/gallery-dl.txt +++ b/src/lib_/gallery-dl.txt @@ -1 +1 @@ -https://github.com/mikf/gallery-dl/releases/download/v1.15.4/gallery-dl.exe \ No newline at end of file +https://github.com/mikf/gallery-dl/releases/download/v1.16.0/gallery-dl.exe \ No newline at end of file diff --git a/src/pyinstaller/data/lib_/SickZil-Machine/src/core.py b/src/pyinstaller/data/lib_/SickZil-Machine/src/core.py index de22af0..0941602 100644 --- a/src/pyinstaller/data/lib_/SickZil-Machine/src/core.py +++ b/src/pyinstaller/data/lib_/SickZil-Machine/src/core.py @@ -1,12 +1,24 @@ import os import consts os.environ['TF_CPP_MIN_LOG_LEVEL'] = consts.TF_CPP_MIN_LOG_LEVEL +os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true' + # NOTE: above only work before tf was imported. import tensorflow as tf import numpy as np import utils.imutils as iu import utils.fp as fp + + +config = tf.ConfigProto() +config.gpu_options.allow_growth = True +graph = tf.Graph() + + + + + seg_limit = 4000000 # dev-machine: state, and init with user info... compl_limit = 657666 # then.. what is the optimal size? def set_limits(slimit, climit): @@ -16,16 +28,20 @@ def set_limits(slimit, climit): def load_model(mpath, version): #graph_def = tf.GraphDef() - graph_def = tf.compat.v1.GraphDef() - #with tf.gfile.GFile(mpath, 'rb') as f: - with tf.io.gfile.GFile(mpath, 'rb') as f: - graph_def.ParseFromString(f.read()) - tf.import_graph_def( - graph_def, - name = consts.model_name(mpath, version) - ) -#load_model(consts.SNETPATH, '0.1.0') -#load_model(consts.CNETPATH, '0.1.0') + + with graph.as_default(): + graph_def = tf.compat.v1.GraphDef() + #with tf.gfile.GFile(mpath, 'rb') as f: + with tf.io.gfile.GFile(mpath, 'rb') as f: + graph_def.ParseFromString(f.read()) + tf.import_graph_def( + graph_def, + name = consts.model_name(mpath, version) + ) +load_model(consts.SNETPATH, '0.1.0') +load_model(consts.CNETPATH, '0.1.0') +sess = tf.Session(config=config,graph=graph) + #---------------------------------------------------------------- def segment_or_oom(segnet, inp, modulo=16): @@ -90,7 +106,7 @@ def assert_img_range(img): def decategorize(mask): return iu.decategorize(mask, iu.rgb2wk_map) - with tf.compat.v1.Session() as sess: + with sess.as_default(): snet_in = consts.snet_in('0.1.0', sess) snet_out = consts.snet_out('0.1.0', sess) def snet(img): @@ -169,7 +185,8 @@ def inpainted(image, segmap): ''' assert (255 >= image).all(), image.max() assert (image >= 0).all(), image.min() - with tf.compat.v1.Session() as sess: + + with sess.as_default(): cnet_in = consts.cnet_in('0.1.0',sess) cnet_out = consts.cnet_out('0.1.0',sess) return inpaint( diff --git a/src/pyinstaller/data/lib_/gallery-dl.exe b/src/pyinstaller/data/lib_/gallery-dl.exe index f137fea..4bd7317 100644 Binary files a/src/pyinstaller/data/lib_/gallery-dl.exe and b/src/pyinstaller/data/lib_/gallery-dl.exe differ diff --git a/src/pyinstaller/data/lib_/gallery-dl.txt b/src/pyinstaller/data/lib_/gallery-dl.txt index 496fac9..9bae2d8 100644 --- a/src/pyinstaller/data/lib_/gallery-dl.txt +++ b/src/pyinstaller/data/lib_/gallery-dl.txt @@ -1 +1 @@ -https://github.com/mikf/gallery-dl/releases/download/v1.15.4/gallery-dl.exe \ No newline at end of file +https://github.com/mikf/gallery-dl/releases/download/v1.16.0/gallery-dl.exe \ No newline at end of file diff --git a/src/text_segmentation.py b/src/text_segmentation.py index f55f29f..72282a0 100644 --- a/src/text_segmentation.py +++ b/src/text_segmentation.py @@ -26,8 +26,7 @@ def imgpath2mask(self, imgpath): imgio.segmap2mask) def segmentPage(self,imgPath,outputInpaintedPath,outputTextOnlyPath): - core.load_model(consts.SNETPATH, '0.1.0') - core.load_model(consts.CNETPATH, '0.1.0') + img = cv2.imread(imgPath) if img.shape[0]>3000: