From: Christian Heller Date: Mon, 19 Aug 2024 09:20:15 +0000 (+0200) Subject: Improve usage help messages. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/task?a=commitdiff_plain;h=54a8a46f406aa203f09b5ef0ee0f2adfa6f354f5;p=stable_plom Improve usage help messages. --- diff --git a/stable.py b/stable.py index 460c0ee..75b6082 100755 --- a/stable.py +++ b/stable.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from sys import argv, exit as sys_exit from os.path import dirname, basename, splitext, join as path_join, exists -from argparse import ArgumentParser +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter from random import randint from stable.core import ImageMaker @@ -15,30 +15,45 @@ def save_path(count: int) -> str: def parse_args(): - parser = ArgumentParser(add_help=False) - parser.add_argument('-m', '--model') - parser.add_argument('-o', '--output') - parser.add_argument('-p', '--prompt') - parser.add_argument('-H', '--help', action='help') - parser.add_argument('--list-schedulers', action='store_true') - parser.add_argument('-C', '--copy-params') - parser.add_argument('-P', '--model_path_prefix', default='', - help='useful if -m is set from -C as mere filename') + parser = ArgumentParser(add_help=False, formatter_class=ArgumentDefaultsHelpFormatter) + parser.add_argument('-m', '--model', + help='model filename (-P will pre prefixed, but may ' + 'also be full path on its own)') + parser.add_argument('-o', '--output', + help='output filename or path; if -q > 1, will insert ' + 'incremented counter number; if no image file ' + 'extension included, defaults to .png') + parser.add_argument('-p', '--prompt', + help='textual guidance to image generation') + parser.add_argument('-q', '--quantity', default=1, type=int, + help='how many pictures to generate (with seed ' + 'auto-incrementing)') parser.add_argument('-h', '--height', default=512, type=int, - help='default: 512') + help='target height in pixels') parser.add_argument('-w', '--width', default=512, type=int, - help='default: 512') + help='target width in pixels') parser.add_argument('-g', '--guidance', default=7.5, type=float, - help='default: 7.5') + help='adherence to text prompt') parser.add_argument('-n', '--n_steps', default=15, type=int, - help='default: 15') - parser.add_argument('-q', '--quantity', default=1, type=int, - help='default: 1') + help='number of denoising steps') parser.add_argument('-s', '--seed', default=1, type=int, - help='default: 1; if set 0, chosen randomnly') + help='randomness seed; set 0 to choose randomly; ' + 'increments if -q > 1') parser.add_argument('-S', '--scheduler', default=DEFAULT_SCHEDULER, - help=f'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 ' + '(e.g. from image file EXIF comment)') + parser.add_argument('-P', '--model_path_prefix', + help='optional directory path prefix to MODEL for ' + 'where it\'s provided as a mere filename (as may ' + 'happen due to -D)') + parser.add_argument('-H', '--help', action='help') + parser.add_argument('-L', '--list-schedulers', action='store_true', + help='list options for -S available with chosen model') parsed_args = parser.parse_args() + parser.set_defaults(model_path_prefix='') if parsed_args.copy_params: first_split = parsed_args.copy_params.split('; PROMPT: ', maxsplit=1) if 2 == len(first_split):