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
93e7dbaa
Commit
93e7dbaa
authored
Aug 28, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for running custom code (primarily to generate various labeled grids)
export for 4chan option
parent
d5266c07
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
48 deletions
+140
-48
README.md
README.md
+43
-0
images/scripting.jpg
images/scripting.jpg
+0
-0
webui.py
webui.py
+97
-48
No files found.
README.md
View file @
93e7dbaa
...
...
@@ -205,3 +205,46 @@ image will be upscaled to twice the original width and height, while width and h
will specify the size of individual tiles. At the moment this method does not support batch size.
![](
images/sd-upscale.jpg
)
### User scripts
If the program is launched with
`--allow-code`
option, an extra text input field for script code
is available in txt2img interface. It allows you to input python code that will do the work with
image. If this field is not empty, the processing that would happen normally is skipped.
In code, access parameters from web UI using the
`p`
variable, and provide outputs for web UI
using the
`display(images, seed, info)`
function. All globals from script are also accessible.
As an example, here is a script that draws a chart seen below (and also saves it as
`test/gnomeplot/gnome5.png`
):
```
python
steps
=
[
4
,
8
,
12
,
16
,
20
]
cfg_scales
=
[
5.0
,
10.0
,
15.0
]
def
cell
(
x
,
y
,
p
=
p
):
p
.
steps
=
x
p
.
cfg_scale
=
y
return
process_images
(
p
)
.
images
[
0
]
images
=
[
draw_xy_grid
(
xs
=
steps
,
ys
=
cfg_scales
,
x_label
=
lambda
x
:
f
'Steps = {x}'
,
y_label
=
lambda
y
:
f
'CFG = {y}'
,
cell
=
cell
)]
save_image
(
images
[
0
],
'test/gnomeplot'
,
'gnome5'
)
display
(
images
)
```
![](
images/scripting.jpg
)
A more simple script that would just process the image and output it normally:
```
python
processed
=
process_images
(
p
)
print
(
"Seed was: "
+
str
(
processed
.
seed
))
display
(
processed
.
images
,
processed
.
seed
,
processed
.
info
)
```
images/scripting.jpg
0 → 100644
View file @
93e7dbaa
1 MB
webui.py
View file @
93e7dbaa
This diff is collapsed.
Click to expand it.
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