diff options
author | David Vorick <david@siasky.net> | 2022-12-13 17:03:16 +0000 |
---|---|---|
committer | David Vorick <david@siasky.net> | 2022-12-13 17:03:16 +0000 |
commit | 27c0504bc4d17eec6e58148ab33c75f5ed2e6f00 (patch) | |
tree | 3ca9997fe4960a65faecce8b97bb70da90f38ab6 | |
parent | 685f9631b56ff8bd43bce24ff5ce0f9a0e9af490 (diff) | |
download | stable-diffusion-webui-gfx803-27c0504bc4d17eec6e58148ab33c75f5ed2e6f00.tar.gz stable-diffusion-webui-gfx803-27c0504bc4d17eec6e58148ab33c75f5ed2e6f00.tar.bz2 stable-diffusion-webui-gfx803-27c0504bc4d17eec6e58148ab33c75f5ed2e6f00.zip |
add support for prompts, negative prompts, and sampler-by-name in text file script
-rw-r--r-- | scripts/prompts_from_file.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/scripts/prompts_from_file.py b/scripts/prompts_from_file.py index 32fe6bdb..6e118ddb 100644 --- a/scripts/prompts_from_file.py +++ b/scripts/prompts_from_file.py @@ -9,6 +9,7 @@ import shlex import modules.scripts as scripts
import gradio as gr
+from modules import sd_samplers
from modules.processing import Processed, process_images
from PIL import Image
from modules.shared import opts, cmd_opts, state
@@ -44,6 +45,7 @@ prompt_tags = { "seed_resize_from_h": process_int_tag,
"seed_resize_from_w": process_int_tag,
"sampler_index": process_int_tag,
+ "sampler_name": process_string_tag,
"batch_size": process_int_tag,
"n_iter": process_int_tag,
"steps": process_int_tag,
@@ -66,14 +68,28 @@ def cmdargs(line): arg = args[pos]
assert arg.startswith("--"), f'must start with "--": {arg}'
+ assert pos+1 < len(args), f'missing argument for command line option {arg}'
+
tag = arg[2:]
+ if tag == "prompt" or tag == "negative_prompt":
+ pos += 1
+ prompt = args[pos]
+ pos += 1
+ while pos < len(args) and not args[pos].startswith("--"):
+ prompt += " "
+ prompt += args[pos]
+ pos += 1
+ res[tag] = prompt
+ continue
+
+
func = prompt_tags.get(tag, None)
assert func, f'unknown commandline option: {arg}'
- assert pos+1 < len(args), f'missing argument for command line option {arg}'
-
val = args[pos+1]
+ if tag == "sampler_name":
+ val = sd_samplers.samplers_map.get(val.lower(), None)
res[tag] = func(val)
|