Browse Source

v1.2.4

master
Ivan Bravo Bravo 3 years ago
parent
commit
fcae108add
  1. 4
      argv/run/__init__.py
  2. 20
      argv/run/argument.py
  3. 2
      argv/run/config.py
  4. 40
      processing/image.py
  5. 4
      utils.py

4
argv/run/__init__.py

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import main
from argv.checkpoints import arg_checkpoints
from argv.common import arg_debug, arg_help, arg_version
from argv.run.argument import arg_altered, arg_auto_rescale, arg_auto_resize, arg_auto_resize_crop, arg_color_transfer,\
from argv.run.argument import arg_altered, arg_export_step, arg_export_step_path, arg_auto_rescale, arg_auto_resize, arg_auto_resize_crop, arg_color_transfer,\
arg_cpu, arg_gpu, arg_ignore_size, arg_input, arg_json_args, arg_json_folder_name, arg_n_run, \
arg_output, arg_overlay, arg_preferences, arg_step, arg_gan_persistent, arg_n_core
@ -35,6 +35,8 @@ def init_run_parser(subparsers): @@ -35,6 +35,8 @@ def init_run_parser(subparsers):
arg_n_run(run_parser)
arg_step(run_parser)
arg_altered(run_parser)
arg_export_step(run_parser)
arg_export_step_path(run_parser)
arg_cpu(processing_mod)
arg_gpu(processing_mod)

20
argv/run/argument.py

@ -11,6 +11,26 @@ def arg_altered(parser): @@ -11,6 +11,26 @@ def arg_altered(parser):
help="Path of the directory where steps images transformation are write."
)
def arg_export_step(parser):
parser.add_argument(
"--export-step",
type=int,
help="Export step image."
"Steps are : \n"
"0 : dress -> correct [OPENCV]\n"
"1 : correct -> mask [GAN]\n"
"2 : mask -> maskref [OPENCV]\n"
"3 : maskref -> maskdet [GAN]\n"
"4 : maskdet -> maskfin [OPENCV]\n"
"5 : maskfin -> nude [GAN]"
)
def arg_export_step_path(parser):
parser.add_argument(
"--export-step-path",
help="Path of the directory where export the step image."
)
def arg_auto_rescale(parser):
parser.add_argument(

2
argv/run/config.py

@ -17,7 +17,7 @@ def set_args_run_parser(args): @@ -17,7 +17,7 @@ def set_args_run_parser(args):
def check_args_run_parser(parser, args):
check_arg_input(parser, args)
check_arg_output(parser, args)
check_args_altered(parser, args)
#check_args_altered(parser, args)
check_arg_checkpoints(parser, args)

40
processing/image.py

@ -39,6 +39,11 @@ class ImageProcessing(Processing): @@ -39,6 +39,11 @@ class ImageProcessing(Processing):
self._args['folder_altered'] = folder_path
path = self._args['folder_altered']
self.__image_steps = [self.__input_path] + [
os.path.join(path, "{}.png".format(p().__class__.__name__))
for p in self.__phases[:self.__starting_step]
]
elif (self.__altered_path):
folder_name = imagename_no_ext + '_' + str(hashlib.md5(open(self.__input_path, 'rb').read()).hexdigest())
folder_path = os.path.join(self.__altered_path, folder_name)
@ -49,10 +54,17 @@ class ImageProcessing(Processing): @@ -49,10 +54,17 @@ class ImageProcessing(Processing):
self.__altered_path = folder_path
path = self.__altered_path
self.__image_steps = [self.__input_path] + [
os.path.join(path, "{}.png".format(p().__class__.__name__))
for p in self.__phases[:self.__starting_step]
]
self.__image_steps = [self.__input_path] + [
os.path.join(path, "{}.png".format(p().__class__.__name__))
for p in self.__phases[:self.__starting_step]
]
else:
# TODO: refactor me, please!
self.__image_steps = [self.__input_path] + [
self.__input_path
for p in self.__phases[0:(self.__starting_step - 1)]
]
Conf.log.info("Processing on {}".format(str(self.__image_steps)[2:-2]))
Conf.log.debug(self.__image_steps)
@ -74,10 +86,28 @@ class ImageProcessing(Processing): @@ -74,10 +86,28 @@ class ImageProcessing(Processing):
:return: None
"""
for p in (x for x in self.__phases[self.__starting_step:self.__ending_step]):
# todo: refactor me, please!
# with this we force the auto-resize for dreamtime, but it is far from ideal
if self.__starting_step == 5:
r = run_worker(self.__phases[0], self.__image_steps, config=self._args)
self.__image_steps.append(r)
for step,p in enumerate(x for x in self.__phases[self.__starting_step:self.__ending_step]):
r = run_worker(p, self.__image_steps, config=self._args)
self.__image_steps.append(r)
# todo: refactor me, please!
if self._args.get('export_step'):
if self._args.get('export_step') == (step-1):
step_path = self._args.get('export_step_path') or os.path.abspath(os.path.join(self.__output_path, '..', 'export.png'))
write_image(r, step_path)
Conf.log.debug("Export Step Image Of {} Execution: {}".format(
camel_case_to_str(p.__name__),
step_path
))
if self.__altered_path:
if (self._args.get('folder_altered')):
path = self._args['folder_altered']

4
utils.py

@ -125,7 +125,9 @@ def cv2_supported_extension(): @@ -125,7 +125,9 @@ def cv2_supported_extension():
:return: <string[]> extensions list
"""
return [".bmp", ".dib", ".jpeg", ".jpg", ".jpe", ".jp2", ".png",
".pbm", ".pgm", "ppm", ".sr", ".ras", ".tiff", ".tif"]
".pbm", ".pgm", "ppm", ".sr", ".ras", ".tiff", ".tif",
".BMP", ".DIB", ".JPEG", ".JPG", ".JPE", ".JP2", ".PNG",
".PBM", ".PGM", "PPM", ".SR", ".RAS", ".TIFF", ".TIF"]
def load_json(a):

Loading…
Cancel
Save