Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
27c0504b
Unverified
Commit
27c0504b
authored
Dec 13, 2022
by
David Vorick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for prompts, negative prompts, and sampler-by-name in text file script
parent
685f9631
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
prompts_from_file.py
scripts/prompts_from_file.py
+18
-2
No files found.
scripts/prompts_from_file.py
View file @
27c0504b
...
@@ -9,6 +9,7 @@ import shlex
...
@@ -9,6 +9,7 @@ import shlex
import
modules.scripts
as
scripts
import
modules.scripts
as
scripts
import
gradio
as
gr
import
gradio
as
gr
from
modules
import
sd_samplers
from
modules.processing
import
Processed
,
process_images
from
modules.processing
import
Processed
,
process_images
from
PIL
import
Image
from
PIL
import
Image
from
modules.shared
import
opts
,
cmd_opts
,
state
from
modules.shared
import
opts
,
cmd_opts
,
state
...
@@ -44,6 +45,7 @@ prompt_tags = {
...
@@ -44,6 +45,7 @@ prompt_tags = {
"seed_resize_from_h"
:
process_int_tag
,
"seed_resize_from_h"
:
process_int_tag
,
"seed_resize_from_w"
:
process_int_tag
,
"seed_resize_from_w"
:
process_int_tag
,
"sampler_index"
:
process_int_tag
,
"sampler_index"
:
process_int_tag
,
"sampler_name"
:
process_string_tag
,
"batch_size"
:
process_int_tag
,
"batch_size"
:
process_int_tag
,
"n_iter"
:
process_int_tag
,
"n_iter"
:
process_int_tag
,
"steps"
:
process_int_tag
,
"steps"
:
process_int_tag
,
...
@@ -66,14 +68,28 @@ def cmdargs(line):
...
@@ -66,14 +68,28 @@ def cmdargs(line):
arg
=
args
[
pos
]
arg
=
args
[
pos
]
assert
arg
.
startswith
(
"--"
),
f
'must start with "--": {arg}'
assert
arg
.
startswith
(
"--"
),
f
'must start with "--": {arg}'
assert
pos
+
1
<
len
(
args
),
f
'missing argument for command line option {arg}'
tag
=
arg
[
2
:]
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
)
func
=
prompt_tags
.
get
(
tag
,
None
)
assert
func
,
f
'unknown commandline option: {arg}'
assert
func
,
f
'unknown commandline option: {arg}'
assert
pos
+
1
<
len
(
args
),
f
'missing argument for command line option {arg}'
val
=
args
[
pos
+
1
]
val
=
args
[
pos
+
1
]
if
tag
==
"sampler_name"
:
val
=
sd_samplers
.
samplers_map
.
get
(
val
.
lower
(),
None
)
res
[
tag
]
=
func
(
val
)
res
[
tag
]
=
func
(
val
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment