Skip to content

Commit

Permalink
v0.3d
Browse files Browse the repository at this point in the history
v0.3d
  • Loading branch information
ttop32 committed Dec 20, 2020
1 parent fb6fd04 commit 4d4a2e5
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 28 deletions.
41 changes: 29 additions & 12 deletions src/lib_/SickZil-Machine/src/core.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down
Binary file modified src/lib_/gallery-dl.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/lib_/gallery-dl.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/mikf/gallery-dl/releases/download/v1.15.4/gallery-dl.exe
https://github.com/mikf/gallery-dl/releases/download/v1.16.0/gallery-dl.exe
41 changes: 29 additions & 12 deletions src/pyinstaller/data/lib_/SickZil-Machine/src/core.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down
Binary file modified src/pyinstaller/data/lib_/gallery-dl.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/pyinstaller/data/lib_/gallery-dl.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/mikf/gallery-dl/releases/download/v1.15.4/gallery-dl.exe
https://github.com/mikf/gallery-dl/releases/download/v1.16.0/gallery-dl.exe
3 changes: 1 addition & 2 deletions src/text_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4d4a2e5

Please sign in to comment.