Browse Source

Added --export-step and --export-step-path to export a specific step in a specific folder.

tags/v1.2.10
Ivan Bravo Bravo 1 year ago
parent
commit
4c1fe64e26
3 changed files with 36 additions and 2 deletions
  1. 3
    1
      argv/run/__init__.py
  2. 21
    0
      argv/run/argument.py
  3. 12
    1
      processing/image.py

+ 3
- 1
argv/run/__init__.py View File

@@ -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):
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)

+ 21
- 0
argv/run/argument.py View File

@@ -11,6 +11,27 @@ 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,
default=4,
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(

+ 12
- 1
processing/image.py View File

@@ -86,10 +86,21 @@ class ImageProcessing(Processing):

:return: None
"""
for p in (x for x in self.__phases[self.__starting_step:self.__ending_step]):
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.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__),
))

if self.__altered_path:
if (self._args.get('folder_altered')):
path = self._args['folder_altered']

Loading…
Cancel
Save