From: Christian Heller Date: Thu, 22 Aug 2024 05:23:42 +0000 (+0200) Subject: Change -D to read from stdin rather than argument string. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/templates?a=commitdiff_plain;h=6eb0f03f49550b04568d2949fdb87190d4c04a0f;p=stable_plom Change -D to read from stdin rather than argument string. --- diff --git a/stable.py b/stable.py index 634add3..665b3a9 100755 --- a/stable.py +++ b/stable.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from sys import argv, exit as sys_exit +from sys import argv, exit as sys_exit, stdin from os.path import dirname, basename, splitext, join as path_join, exists from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter from random import randint @@ -42,8 +42,8 @@ def parse_args(): parser.add_argument('-S', '--scheduler', default=DEFAULT_SCHEDULER, help='name of denoising scheduler; --list-schedulers ' 'prints available choices for chosen model') - parser.add_argument('-D', '--defaults_from_params_string', - help='string to parse for image generation options ' + parser.add_argument('-D', '--defaults_from_stdin', action='store_true', + help='parse stdin for image generation options ' '(e.g. from image file EXIF comment)') parser.add_argument('-P', '--model_path_prefix', help='optional directory path prefix to MODEL for ' @@ -54,9 +54,9 @@ def parse_args(): help='list options for -S available with chosen model') parsed_args = parser.parse_args() parser.set_defaults(model_path_prefix='') - if parsed_args.defaults_from_params_string: - first_split = parsed_args.\ - defaults_from_params_string.split('; PROMPT: ', maxsplit=1) + if parsed_args.defaults_from_stdin: + defaults_string = stdin.read() + first_split = defaults_string.split('; PROMPT: ', maxsplit=1) if 2 == len(first_split): parser.set_defaults(prompt=first_split[1]) for section in first_split[0].split('; '):