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
f8e219ba
Commit
f8e219ba
authored
Mar 03, 2023
by
Vladimir Mandic
Committed by
GitHub
Mar 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow api requests to specify do not send images in response
parent
23d4fb5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
modules/api/api.py
modules/api/api.py
+8
-2
modules/api/models.py
modules/api/models.py
+16
-2
No files found.
modules/api/api.py
View file @
f8e219ba
...
@@ -190,6 +190,9 @@ class Api:
...
@@ -190,6 +190,9 @@ class Api:
args
=
vars
(
populate
)
args
=
vars
(
populate
)
args
.
pop
(
'script_name'
,
None
)
args
.
pop
(
'script_name'
,
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
)
with
self
.
queue_lock
:
with
self
.
queue_lock
:
p
=
StableDiffusionProcessingTxt2Img
(
sd_model
=
shared
.
sd_model
,
**
args
)
p
=
StableDiffusionProcessingTxt2Img
(
sd_model
=
shared
.
sd_model
,
**
args
)
...
@@ -203,7 +206,7 @@ class Api:
...
@@ -203,7 +206,7 @@ class Api:
processed
=
process_images
(
p
)
processed
=
process_images
(
p
)
shared
.
state
.
end
()
shared
.
state
.
end
()
b64images
=
list
(
map
(
encode_pil_to_base64
,
processed
.
images
))
b64images
=
list
(
map
(
encode_pil_to_base64
,
processed
.
images
))
if
send_images
else
[]
return
TextToImageResponse
(
images
=
b64images
,
parameters
=
vars
(
txt2imgreq
),
info
=
processed
.
js
())
return
TextToImageResponse
(
images
=
b64images
,
parameters
=
vars
(
txt2imgreq
),
info
=
processed
.
js
())
...
@@ -232,6 +235,9 @@ class Api:
...
@@ -232,6 +235,9 @@ 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
(
'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
)
args
.
pop
(
'script_name'
,
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
)
with
self
.
queue_lock
:
with
self
.
queue_lock
:
p
=
StableDiffusionProcessingImg2Img
(
sd_model
=
shared
.
sd_model
,
**
args
)
p
=
StableDiffusionProcessingImg2Img
(
sd_model
=
shared
.
sd_model
,
**
args
)
p
.
init_images
=
[
decode_base64_to_image
(
x
)
for
x
in
init_images
]
p
.
init_images
=
[
decode_base64_to_image
(
x
)
for
x
in
init_images
]
...
@@ -246,7 +252,7 @@ class Api:
...
@@ -246,7 +252,7 @@ class Api:
processed
=
process_images
(
p
)
processed
=
process_images
(
p
)
shared
.
state
.
end
()
shared
.
state
.
end
()
b64images
=
list
(
map
(
encode_pil_to_base64
,
processed
.
images
))
b64images
=
list
(
map
(
encode_pil_to_base64
,
processed
.
images
))
if
send_images
else
[]
if
not
img2imgreq
.
include_init_images
:
if
not
img2imgreq
.
include_init_images
:
img2imgreq
.
init_images
=
None
img2imgreq
.
init_images
=
None
...
...
modules/api/models.py
View file @
f8e219ba
...
@@ -100,13 +100,27 @@ class PydanticModelGenerator:
...
@@ -100,13 +100,27 @@ class PydanticModelGenerator:
StableDiffusionTxt2ImgProcessingAPI
=
PydanticModelGenerator
(
StableDiffusionTxt2ImgProcessingAPI
=
PydanticModelGenerator
(
"StableDiffusionProcessingTxt2Img"
,
"StableDiffusionProcessingTxt2Img"
,
StableDiffusionProcessingTxt2Img
,
StableDiffusionProcessingTxt2Img
,
[{
"key"
:
"sampler_index"
,
"type"
:
str
,
"default"
:
"Euler"
},
{
"key"
:
"script_name"
,
"type"
:
str
,
"default"
:
None
},
{
"key"
:
"script_args"
,
"type"
:
list
,
"default"
:
[]}]
[
{
"key"
:
"sampler_index"
,
"type"
:
str
,
"default"
:
"Euler"
},
{
"key"
:
"script_name"
,
"type"
:
str
,
"default"
:
None
},
{
"key"
:
"script_args"
,
"type"
:
list
,
"default"
:
[]},
{
"key"
:
"do_not_send_images"
,
"type"
:
bool
,
"default"
:
False
}
]
)
.
generate_model
()
)
.
generate_model
()
StableDiffusionImg2ImgProcessingAPI
=
PydanticModelGenerator
(
StableDiffusionImg2ImgProcessingAPI
=
PydanticModelGenerator
(
"StableDiffusionProcessingImg2Img"
,
"StableDiffusionProcessingImg2Img"
,
StableDiffusionProcessingImg2Img
,
StableDiffusionProcessingImg2Img
,
[{
"key"
:
"sampler_index"
,
"type"
:
str
,
"default"
:
"Euler"
},
{
"key"
:
"init_images"
,
"type"
:
list
,
"default"
:
None
},
{
"key"
:
"denoising_strength"
,
"type"
:
float
,
"default"
:
0.75
},
{
"key"
:
"mask"
,
"type"
:
str
,
"default"
:
None
},
{
"key"
:
"include_init_images"
,
"type"
:
bool
,
"default"
:
False
,
"exclude"
:
True
},
{
"key"
:
"script_name"
,
"type"
:
str
,
"default"
:
None
},
{
"key"
:
"script_args"
,
"type"
:
list
,
"default"
:
[]}]
[
{
"key"
:
"sampler_index"
,
"type"
:
str
,
"default"
:
"Euler"
},
{
"key"
:
"init_images"
,
"type"
:
list
,
"default"
:
None
},
{
"key"
:
"denoising_strength"
,
"type"
:
float
,
"default"
:
0.75
},
{
"key"
:
"mask"
,
"type"
:
str
,
"default"
:
None
},
{
"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_images"
,
"type"
:
bool
,
"default"
:
False
}
]
)
.
generate_model
()
)
.
generate_model
()
class
TextToImageResponse
(
BaseModel
):
class
TextToImageResponse
(
BaseModel
):
...
...
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