Skip to content

Commit

Permalink
Added scheduler support, fixes mcmonkeyprojects#143
Browse files Browse the repository at this point in the history
Signed-off-by: Jaid <[email protected]>
  • Loading branch information
Jaid committed Jul 14, 2024
1 parent 0082d79 commit 2dae1b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,30 @@ The disadvantage is that time to generate a grid is exponential - if you have 5

### Table of Contents

- [Examples](#Examples)
- [Status](#Status)
- [Installation](#Installation)
- [Basic Usage](#Basic-Usage)
- [Advanced Usage](#Advanced-Usage)
- [Stable Diffusion Infinity Grid Generator](#stable-diffusion-infinity-grid-generator)
- [Concept](#concept)
- [Goals and Use Cases](#goals-and-use-cases)
- [Pros/Cons](#proscons)
- [Table of Contents](#table-of-contents)
- [Examples](#examples)
- [Status](#status)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Advanced Usage](#advanced-usage)
- [1: Grid Definition File](#1-grid-definition-file)
- [Settings supported for parameters](#settings-supported-for-parameters)
- [Supported Extensions](#supported-extensions)
- [Dynamic Thresholding (CFG Scale Fix)](#dynamic-thresholding-cfg-scale-fix)
- [ControlNet](#controlnet)
- [Dynamic Thresholding (CFG Scale Fix)](#dynamic-thresholding-cfg-scale-fix)
- [ControlNet](#controlnet)
- [Other Extensions](#other-extensions)
- [2: Grid Content Generation via WebUI](#2-grid-content-generation-via-webui)
- [3: Using The Output](#3-using-the-output)
- [4: Expanding Later](#4-expanding-later)
- [Credits](#credits)
- [Common Issues](#common-issues)
- [License](#License)
- [Credits](#credits)
- [Common Issues](#common-issues)
- [Licensing pre-note:](#licensing-pre-note)
- [The short of the license is:](#the-short-of-the-license-is)
- [The long version of the license follows:](#the-long-version-of-the-license-follows)

--------------

Expand Down Expand Up @@ -153,6 +162,7 @@ axes:
| Name | Type | Example | Notes |
| --- | --- | --- | ----------- |
| `Sampler` | Named | `DDIM`, `euler`, ... | |
| `Scheduler` | Named | `Automatic`, `Karras`, ... | |
| `Model` | Filename | `sd-v1-5` | Note that `Model` and `VAE` are **global settings**, and as such you should not have an axis where some values specify one of those params but others don't, as this will cause an unpredictable model selection for the values that lack specificity. |
| `VAE` | Filename | `kl-f8-anime2` | See note on `Model` above |
| `Prompt` | Text | `a cat` | |
Expand Down
3 changes: 2 additions & 1 deletion assets/a1111webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ function formatMetadata(valSet) {
if (negative.length > 0) {
negative = '\nNegative prompt: ' + negative;
}
const handled = ['steps', 'sampler', 'cfgscale', 'seed', 'restorefaces', 'width', 'height', 'model', 'varseed', 'varstrength', 'denoising', 'eta', 'clipskip', 'vae', 'sigmachurn', 'sigmatmin', 'sigmatmax', 'sigmanoise', 'prompt', 'negativeprompt', 'codeformerweight'];
const handled = ['steps', 'sampler', 'scheduler', 'cfgscale', 'seed', 'restorefaces', 'width', 'height', 'model', 'varseed', 'varstrength', 'denoising', 'eta', 'clipskip', 'vae', 'sigmachurn', 'sigmatmin', 'sigmatmax', 'sigmanoise', 'prompt', 'negativeprompt', 'codeformerweight'];
var keyData = formatMet('Steps', valSet['steps'])
+ formatMet('Scheduler', valSet['scheduler'])
+ formatMet('Sampler', valSet['sampler'])
+ formatMet('CFG scale', valSet['cfgscale'])
+ formatMet('Seed', valSet['seed'])
Expand Down
5 changes: 3 additions & 2 deletions assets/grid.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/definitions/Axis"
"$ref": "#/definitions/Axis"
}
},
"title": "Axes"
Expand Down Expand Up @@ -77,7 +77,7 @@
"Value": {
"oneOf": [{
"type": "string",
"pattern": "(Sampler|sampler|Model|model|VAE|vae|Prompt|prompt|NegativePrompt|negativeprompt|Negative Prompt|negative prompt|PromptReplace|promptreplace|Prompt Replace|prompt replace|Prompt Replace|prompt replace|Seed|seed|Steps|steps|CFGScale|cfgscale|CFG Scale|cfg scale|CFGscale|CFG scale|Width|width|Height|height|OutWidth|outwidth|Out Width|out width|OutHeight|outheight|Out Height|out height|ClipSkip|clipskip|Clip Skip|clip skip|VarSeed|varseed|Var Seed|var seed|VarStrength|varstrength|Var Strength|var strength|CodeFormerWeight|codeformerweight|CodeFormer Weight|codeformer weight|Denoising|denoising|ETA|eta|ETANoiseSeedDelta|etanoiseseeddelta|ETA Noise Seed Delta|eta noise seed delta|SigmaChurn|sigmachurn|Sigma Churn|sigma churn|SigmaTmin|sigmatmin|Sigma Tmin|sigma tmin|SigmaTmax|sigmatmax|Sigma Tmax|sigma tmax|SigmaNoise|sigmanoise|Sigma Noise|sigma noise|Tiling|tiling|ImageMaskWeight|imagemaskweight|Image Mask Weight|image mask weight|EnableHighresFix|enablehighresfix|Enable Highres Fix|enable highres fix|HighresScale|highresscale|Highres Scale|highres scale|HighresSteps|highressteps|Highres Steps|highres steps|HighresUpscaler|highresupscaler|Highres Upscaler|highres upscaler|HighresResizeWidth|highresresizewidth|Highres Resize Width|highres resize width|HighresResizeHeight|highresresizeheight|Highres Resize Height|highres resize height|HighresUpscaleToWidth|highresupscaletowidth|Highres Upscale To Width|highres upscale to width|HighresUpscaleToHeight|highresupscaletoheight|Highres Upscale To Height|highres upscale to height|RestoreFaces|Restore Faces|restorefaces|restore faces|([dD]ynamic\\s?[Tt]hreshold.*)|)\\=.*"
"pattern": "(Sampler|sampler|Scheduler|scheduler|Model|model|VAE|vae|Prompt|prompt|NegativePrompt|negativeprompt|Negative Prompt|negative prompt|PromptReplace|promptreplace|Prompt Replace|prompt replace|Prompt Replace|prompt replace|Seed|seed|Steps|steps|CFGScale|cfgscale|CFG Scale|cfg scale|CFGscale|CFG scale|Width|width|Height|height|OutWidth|outwidth|Out Width|out width|OutHeight|outheight|Out Height|out height|ClipSkip|clipskip|Clip Skip|clip skip|VarSeed|varseed|Var Seed|var seed|VarStrength|varstrength|Var Strength|var strength|CodeFormerWeight|codeformerweight|CodeFormer Weight|codeformer weight|Denoising|denoising|ETA|eta|ETANoiseSeedDelta|etanoiseseeddelta|ETA Noise Seed Delta|eta noise seed delta|SigmaChurn|sigmachurn|Sigma Churn|sigma churn|SigmaTmin|sigmatmin|Sigma Tmin|sigma tmin|SigmaTmax|sigmatmax|Sigma Tmax|sigma tmax|SigmaNoise|sigmanoise|Sigma Noise|sigma noise|Tiling|tiling|ImageMaskWeight|imagemaskweight|Image Mask Weight|image mask weight|EnableHighresFix|enablehighresfix|Enable Highres Fix|enable highres fix|HighresScale|highresscale|Highres Scale|highres scale|HighresSteps|highressteps|Highres Steps|highres steps|HighresUpscaler|highresupscaler|Highres Upscaler|highres upscaler|HighresResizeWidth|highresresizewidth|Highres Resize Width|highres resize width|HighresResizeHeight|highresresizeheight|Highres Resize Height|highres resize height|HighresUpscaleToWidth|highresupscaletowidth|Highres Upscale To Width|highres upscale to width|HighresUpscaleToHeight|highresupscaletoheight|Highres Upscale To Height|highres upscale to height|RestoreFaces|Restore Faces|restorefaces|restore faces|([dD]ynamic\\s?[Tt]hreshold.*)|)\\=.*"
},
{
"type": "object",
Expand Down Expand Up @@ -139,6 +139,7 @@
"additionalProperties": false,
"properties": {
"Sampler": { "type": "string" }, "sampler": { "type": "string" },
"Scheduler": { "type": "string" }, "scheduler": { "type": "string" },
"Model": { "type": "string" }, "model": { "type": "string" },
"VAE": { "type": "string" }, "vae": { "type": "string" },
"Prompt": { "type": "string" }, "prompt": { "type": "string" },
Expand Down
4 changes: 3 additions & 1 deletion scripts/infinity_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def try_init():
registerMode("Model", GridSettingMode(dry=False, type="text", apply=apply_model, clean=clean_model, valid_list=lambda: list(map(lambda m: m.title, sd_models.checkpoints_list.values()))))
registerMode("VAE", GridSettingMode(dry=False, type="text", apply=apply_vae, clean=clean_vae, valid_list=lambda: list(sd_vae.vae_dict.keys()) + ['none', 'auto', 'automatic']))
registerMode("Sampler", GridSettingMode(dry=True, type="text", apply=apply_field("sampler_name"), valid_list=lambda: list(sd_samplers.all_samplers_map.keys())))
registerMode("Scheduler", GridSettingMode(dry=True, type="text", apply=apply_field("scheduler"), valid_list=lambda: list(shared.schedulers.schedulers.keys())))
registerMode("Seed", GridSettingMode(dry=True, type="integer", apply=apply_field("seed")))
registerMode("Steps", GridSettingMode(dry=True, type="integer", min=0, max=200, apply=apply_field("steps")))
registerMode("CFG Scale", GridSettingMode(dry=True, type="decimal", min=0, max=500, apply=apply_field("cfg_scale")))
Expand Down Expand Up @@ -235,7 +236,7 @@ def a1111_grid_call_param_add_hook(grid_call: core.SingleGridCall, param: str, v
def a1111_grid_call_apply_hook(grid_call: core.SingleGridCall, param: str, dry: bool):
for replace in grid_call.replacements:
apply_prompt_replace(param, replace)

def a1111_grid_runner_pre_run_hook(grid_runner: core.GridRunner):
state.job_count = grid_runner.total_run
shared.total_tqdm.updateTotal(grid_runner.total_steps)
Expand Down Expand Up @@ -297,6 +298,7 @@ def a1111_grid_runner_count_steps(grid_runner: core.GridRunner, set):
def a1111_webdata_get_base_param_data(p):
return {
"sampler": p.sampler_name,
"scheduler": p.scheduler,
"seed": p.seed,
"restorefaces": (opts.face_restoration_model if p.restore_faces else None),
"steps": p.steps,
Expand Down

0 comments on commit 2dae1b1

Please sign in to comment.