Skip to content

Commit d333a7a

Browse files
committed
Continued work on UI and sample inputs
1 parent a483bc1 commit d333a7a

File tree

5 files changed

+103
-9
lines changed

5 files changed

+103
-9
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TODO
3636
- Open the WebUI
3737
- Go to the `txt2img` or `img2img` tab
3838
- At the bottom of the page, find the `Script` selection box, and select `Generate Infinite-Axis Grid`
39-
- Select options at will. You can hover over each option for extra usage information.
39+
- Select options at will. You can hover your mouse over each option for extra usage information.
4040
- Select your grid definition file from earlier.
4141
- Hit your `Generate` button, and wait.
4242

Diff for: assets/short_example.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This is a YAML file, so all content must be configured per YAML specification.
2+
3+
# This key is required configuration of the grid itself.
4+
grid:
5+
# Give a page title
6+
title: My Short Example Grid
7+
# Give a page description
8+
description: >
9+
This is to demonstrate the concept of how the infinite-axis grid system works.
10+
This description here demonstrates multi-line YAML strings.
11+
<br>It also shows that you can write <b>HTML</b> if you want to.
12+
13+
# "axes" is the root key of the list of axes
14+
axes:
15+
# Simply number these keys.
16+
# The key names are ignored and just used to organize the file, so feel free to put random values here instead if you want to I guess.
17+
1:
18+
# Name your axis.
19+
name: Sampler
20+
# Add any description text you want.
21+
description: Different samplers can produce slightly different output.
22+
# "values" is where the options go
23+
values:
24+
# Again, number the keys.
25+
1:
26+
# As usual, name and optional description.
27+
name: Euler A
28+
description: Euler Ancestral is like Euler, but with <b>ancestral</b> stuff.
29+
# You can configure multiple parameter settings arbitrarily here.
30+
params:
31+
# View the readme for accepted parameter types and formats.
32+
Sampler: Euler A
33+
2:
34+
name: Euler
35+
description: Good ol k_euler.
36+
params:
37+
Sampler: Euler
38+
3:
39+
name: DDIM
40+
description: The original.
41+
params:
42+
Sampler: DDIM
43+
2:
44+
name: Steps
45+
description: How many times to run the sampler.
46+
values:
47+
1:
48+
name: 10
49+
description: Ten times.
50+
params:
51+
Steps: 10
52+
# You can be lazy too. This will set param 'steps' to '15' and set name to '15'.
53+
2: steps=15
54+
3: steps=20
55+
3:
56+
name: CFG Scale
57+
values:
58+
1: CFG scale=3
59+
2: CFG scale=5
60+
3: CFG scale=7
61+
4: CFG scale=9
62+
5: CFG scale=11
63+
4:
64+
name: Seed
65+
values:
66+
1: seed=1
67+
2: seed=2
68+
3: seed=3
69+

Diff for: javascript/infinity_grid.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ ex_titles = titles;
1616

1717
new_titles = {
1818
"Save Grid Images As JPEG": "If checked, images in the infinity grid will be simple JPEG files. These use less space, but will be missing metadata. If unchecked, images will be PNG files, which have metadata or other custom settings, at the cost of using much more filespace.",
19-
"Select grid definition file": "Select the grid definition yaml file, in your '(extension)/assets' folder. Refer to the README for info."
19+
"Select grid definition file": "Select the grid definition yaml file, in your '(extension)/assets' folder. Refer to the README for info.",
20+
"Overwrite existing images (for updating grids)": "If checked, any existing image files will be overwritten - this is useful if you want to redo the grid with completely different base settings. If unchecked, if an image already exists, it will be skipped - this is useful for adding new options to an existing grid."
2021
}
2122

2223
ex_titles = Object.assign({}, ex_titles, new_titles);

Diff for: scripts/infinity_grid.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,46 @@
2020
from modules.processing import Processed
2121
from modules.shared import opts, cmd_opts, state
2222

23+
refresh_symbol = '\U0001f504' # 🔄
2324
INF_GRID_README = "https://github.com/mcmonkeyprojects/sd-infinity-grid-generator-script"
2425

2526
class GridFileHelper:
2627

2728
def getNameList():
28-
return glob.glob(scripts.basedir() + "/assets/*.yml")
29+
relPath = os.path.join(Script.BASEDIR, "assets")
30+
fileList = glob.glob(relPath + "/*.yml")
31+
justFileNames = list(map(lambda f: os.path.relpath(f, relPath), fileList))
32+
print(f"rel {relPath} files {fileList} justName {justFileNames}")
33+
return justFileNames
2934

3035
class Script(scripts.Script):
3136

37+
BASEDIR = scripts.basedir()
38+
3239
def title(self):
3340
return "Generate Infinite-Axis Grid"
3441

3542
def show(self, is_img2img):
3643
return True
3744

38-
3945
def ui(self, is_img2img):
40-
help_info = gr.Label(label=f"Confused/new? View <a href=\"{INF_GRID_README}\">the README</a> for usage instructions.")
46+
help_info = gr.HTML(value=f"<br>Confused/new? View <a style=\"border-bottom: 1px #00ffff dotted;\" href=\"{INF_GRID_README}\">the README</a> for usage instructions.<br><br>")
4147
use_jpg = gr.Checkbox(value=True, label="Save Grid Images As JPEG")
42-
grid_file = gr.Dropdown(value=None,label="Select grid definition file", choices=GridFileHelper.getNameList())
48+
do_overwrite = gr.Checkbox(value=False, label="Overwrite existing images (for updating grids)")
49+
# Maintain our own refreshable list of yaml files, to avoid all the oddities of other scripts demanding you drag files and whatever
50+
# Refresh code based roughly on how the base WebUI does refreshing of model files and all
51+
with gr.Row():
52+
grid_file = gr.Dropdown(value=None,label="Select grid definition file", choices=GridFileHelper.getNameList())
53+
def refresh():
54+
newChoices = GridFileHelper.getNameList()
55+
grid_file.choices = newChoices
56+
return gr.update(choices=newChoices)
57+
refresh_button = gr.Button(value=refresh_symbol, elem_id="infinity_grid_refresh_button")
58+
refresh_button.click(fn=refresh, inputs=[], outputs=[grid_file])
4359
# TODO
44-
return [help_info, use_jpg, grid_file]
45-
60+
return [help_info, use_jpg, do_overwrite, grid_file, refresh_button]
4661

47-
def run(self, p, use_jpg, grid_file):
62+
def run(self, p, help_info, use_jpg, do_overwrite, grid_file, refresh_button):
4863
# TODO
4964
proc = process_images(p)
5065
return proc

Diff for: style.css

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This file is part of Stable Diffusion Infinity Grid Generator, view the README.md for more information.
3+
*/
4+
5+
#infinity_grid_refresh_button {
6+
max-width: 2.5em;
7+
min-width: 2.5em;
8+
height: 2.4em;
9+
}

0 commit comments

Comments
 (0)