Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
3531a500
Commit
3531a500
authored
Mar 11, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename fields for API for saving/sending images
save images to correct directories
parent
bb3ecc32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
31 deletions
+21
-31
modules/api/api.py
modules/api/api.py
+17
-24
modules/api/models.py
modules/api/models.py
+4
-4
modules/images.py
modules/images.py
+0
-3
No files found.
modules/api/api.py
View file @
3531a500
...
...
@@ -178,29 +178,27 @@ class Api:
def
text2imgapi
(
self
,
txt2imgreq
:
StableDiffusionTxt2ImgProcessingAPI
):
script
,
script_idx
=
self
.
get_script
(
txt2imgreq
.
script_name
,
scripts
.
scripts_txt2img
)
populate
=
txt2imgreq
.
copy
(
update
=
{
# Override __init__ params
populate
=
txt2imgreq
.
copy
(
update
=
{
# Override __init__ params
"sampler_name"
:
validate_sampler_name
(
txt2imgreq
.
sampler_name
or
txt2imgreq
.
sampler_index
),
"do_not_save_samples"
:
txt2imgreq
.
do_not_save
,
"do_not_save_grid"
:
txt2imgreq
.
do_not_save
,
}
)
"do_not_save_samples"
:
not
txt2imgreq
.
save_images
,
"do_not_save_grid"
:
not
txt2imgreq
.
save_images
,
})
if
populate
.
sampler_name
:
populate
.
sampler_index
=
None
# prevent a warning later on
args
=
vars
(
populate
)
args
.
pop
(
'script_name'
,
None
)
send_images
=
True
if
not
'do_not_send'
in
args
else
not
args
[
'do_not_send'
]
args
.
pop
(
'do_not_send'
,
None
)
args
.
pop
(
'do_not_save'
,
None
)
send_images
=
args
.
pop
(
'send_images'
,
True
)
args
.
pop
(
'save_images'
,
None
)
with
self
.
queue_lock
:
p
=
StableDiffusionProcessingTxt2Img
(
sd_model
=
shared
.
sd_model
,
**
args
)
p
.
outpath_grids
=
opts
.
outdir_txt2img_grids
p
.
outpath_samples
=
opts
.
outdir_txt2img_samples
shared
.
state
.
begin
()
if
script
is
not
None
:
p
.
outpath_grids
=
opts
.
outdir_txt2img_grids
p
.
outpath_samples
=
opts
.
outdir_txt2img_samples
p
.
script_args
=
[
script_idx
+
1
]
+
[
None
]
*
(
script
.
args_from
-
1
)
+
p
.
script_args
processed
=
scripts
.
scripts_txt2img
.
run
(
p
,
*
p
.
script_args
)
else
:
...
...
@@ -222,13 +220,12 @@ class Api:
if
mask
:
mask
=
decode_base64_to_image
(
mask
)
populate
=
img2imgreq
.
copy
(
update
=
{
# Override __init__ params
populate
=
img2imgreq
.
copy
(
update
=
{
# Override __init__ params
"sampler_name"
:
validate_sampler_name
(
img2imgreq
.
sampler_name
or
img2imgreq
.
sampler_index
),
"do_not_save_samples"
:
img2imgreq
.
do_not_save
,
"do_not_save_grid"
:
img2imgreq
.
do_not_save
,
"mask"
:
mask
}
)
"do_not_save_samples"
:
not
img2imgreq
.
save_images
,
"do_not_save_grid"
:
not
img2imgreq
.
save_images
,
"mask"
:
mask
,
})
if
populate
.
sampler_name
:
populate
.
sampler_index
=
None
# prevent a warning later on
...
...
@@ -236,21 +233,17 @@ class Api:
args
.
pop
(
'include_init_images'
,
None
)
# this is meant to be done by "exclude": True in model, but it's for a reason that I cannot determine.
args
.
pop
(
'script_name'
,
None
)
send_images
=
True
if
not
'do_not_send'
in
args
else
not
args
[
'do_not_send'
]
args
.
pop
(
'do_not_send'
,
None
)
args
.
pop
(
'do_not_save'
,
None
)
send_images
=
True
if
not
'do_not_send_images'
in
args
else
not
args
[
'do_not_send_images'
]
args
.
pop
(
'do_not_send_images'
,
None
)
send_images
=
args
.
pop
(
'send_images'
,
True
)
args
.
pop
(
'save_images'
,
None
)
with
self
.
queue_lock
:
p
=
StableDiffusionProcessingImg2Img
(
sd_model
=
shared
.
sd_model
,
**
args
)
p
.
init_images
=
[
decode_base64_to_image
(
x
)
for
x
in
init_images
]
p
.
outpath_grids
=
opts
.
outdir_img2img_grids
p
.
outpath_samples
=
opts
.
outdir_img2img_samples
shared
.
state
.
begin
()
if
script
is
not
None
:
p
.
outpath_grids
=
opts
.
outdir_img2img_grids
p
.
outpath_samples
=
opts
.
outdir_img2img_samples
p
.
script_args
=
[
script_idx
+
1
]
+
[
None
]
*
(
script
.
args_from
-
1
)
+
p
.
script_args
processed
=
scripts
.
scripts_img2img
.
run
(
p
,
*
p
.
script_args
)
else
:
...
...
modules/api/models.py
View file @
3531a500
...
...
@@ -104,8 +104,8 @@ StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator(
{
"key"
:
"sampler_index"
,
"type"
:
str
,
"default"
:
"Euler"
},
{
"key"
:
"script_name"
,
"type"
:
str
,
"default"
:
None
},
{
"key"
:
"script_args"
,
"type"
:
list
,
"default"
:
[]},
{
"key"
:
"
do_not_send"
,
"type"
:
bool
,
"default"
:
Fals
e
},
{
"key"
:
"
do_not_save"
,
"type"
:
bool
,
"default"
:
True
}
{
"key"
:
"
send_images"
,
"type"
:
bool
,
"default"
:
Tru
e
},
{
"key"
:
"
save_images"
,
"type"
:
bool
,
"default"
:
False
},
]
)
.
generate_model
()
...
...
@@ -120,8 +120,8 @@ StableDiffusionImg2ImgProcessingAPI = PydanticModelGenerator(
{
"key"
:
"include_init_images"
,
"type"
:
bool
,
"default"
:
False
,
"exclude"
:
True
},
{
"key"
:
"script_name"
,
"type"
:
str
,
"default"
:
None
},
{
"key"
:
"script_args"
,
"type"
:
list
,
"default"
:
[]},
{
"key"
:
"
do_not_send"
,
"type"
:
bool
,
"default"
:
Fals
e
},
{
"key"
:
"
do_not_save"
,
"type"
:
bool
,
"default"
:
True
}
{
"key"
:
"
send_images"
,
"type"
:
bool
,
"default"
:
Tru
e
},
{
"key"
:
"
save_images"
,
"type"
:
bool
,
"default"
:
False
},
]
)
.
generate_model
()
...
...
modules/images.py
View file @
3531a500
...
...
@@ -489,9 +489,6 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
"""
namegen
=
FilenameGenerator
(
p
,
seed
,
prompt
,
image
)
if
path
is
None
:
# set default path to avoid errors when functions are triggered manually or via api and param is not set
path
=
opts
.
outdir_save
if
save_to_dirs
is
None
:
save_to_dirs
=
(
grid
and
opts
.
grid_save_to_dirs
)
or
(
not
grid
and
opts
.
save_to_dirs
and
not
no_prompt
)
...
...
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