add more parameters, so that the script can run in non interactive mode

This commit is contained in:
AdamBear 2022-08-18 16:54:21 +08:00
parent cd83f6fedf
commit 51eccfb5a3
5 changed files with 333 additions and 195 deletions

View file

@ -26,7 +26,10 @@ def main (model_class_name=None,
output_mask_path=None,
aligned_path=None,
force_gpu_idxs=None,
cpu_only=None):
cpu_only=None,
is_interactive=None,
config=None,
subprocess_count=0):
io.log_info ("Running merger.\r\n")
try:
@ -69,12 +72,16 @@ def main (model_class_name=None,
place_model_on_cpu=True,
run_on_cpu=run_on_cpu)
is_interactive = io.input_bool ("Use interactive merger?", True) if not io.is_colab() else False
if is_interactive is None:
is_interactive = io.input_bool ("Use interactive merger?", True) if not io.is_colab() else False
if not is_interactive:
if not is_interactive and not config:
cfg.ask_settings()
subprocess_count = io.input_int("Number of workers?", max(8, multiprocessing.cpu_count()),
else:
cfg = config
if subprocess_count <= 0:
subprocess_count = io.input_int("Number of workers?", max(8, multiprocessing.cpu_count()),
valid_range=[1, multiprocessing.cpu_count()], help_message="Specify the number of threads to process. A low value may affect performance. A high value may result in memory error. The value may not be greater than CPU cores." )
input_path_image_paths = pathex.get_image_paths(input_path)