From: Christian Heller Date: Mon, 19 Aug 2024 05:36:37 +0000 (+0200) Subject: Improve parameter parsing. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/template?a=commitdiff_plain;h=c6bea3ac33a9b48db9174ef2e53ed8735eda931f;p=stable_plom Improve parameter parsing. --- diff --git a/stable.py b/stable.py index be5d135..460c0ee 100755 --- a/stable.py +++ b/stable.py @@ -40,14 +40,18 @@ def parse_args(): help=f'default: {DEFAULT_SCHEDULER}') parsed_args = parser.parse_args() if parsed_args.copy_params: - for section in parsed_args.copy_params.split('; '): + first_split = parsed_args.copy_params.split('; PROMPT: ', maxsplit=1) + if 2 == len(first_split): + parser.set_defaults(prompt=first_split[1]) + for section in first_split[0].split('; '): key, val = section.split(': ', maxsplit=1) key = key.lower() if key in {'seed', 'height', 'width', 'n_steps'}: val = int(val) elif key in {'guidance'}: val = float(val) - setattr(parsed_args, key, val) + parser.set_defaults(**{key: val}) + parsed_args = parser.parse_args() prefix = f'{argv[0]}: error: ' if parsed_args.list_schedulers: required = {'model': 'm'} diff --git a/stable/core.py b/stable/core.py index d89d4a9..a5f7b56 100644 --- a/stable/core.py +++ b/stable/core.py @@ -23,6 +23,8 @@ class ImageMaker: return self.target not in record.getMessage() self.model_filename = basename(model_path) + if '; ' in self.model_filename: + raise Exception('illegal filename (must not contain "; ")') self.seed = None self.prompt = None self.guidance = None