puts default scripts into separate file, begins possibility of user-defined script file
This commit is contained in:
parent
c8ef073531
commit
c41ec4be46
4 changed files with 50 additions and 67 deletions
16
defaultscripts.json
Normal file
16
defaultscripts.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"defaultScripts": {
|
||||
"Loopback": {
|
||||
"titleText": "Params:\nloops (int) //def: 8\ndenoising_strength_change_factor (decimal, 0.90-1.10) //def: 0.99",
|
||||
"scriptValues": "[8, 0.99]"
|
||||
},
|
||||
"Prompt matrix": {
|
||||
"titleText": "Params:\nput_at_start (bool): expect pipe (|) delimited options at start of prompt //def: false\ndifferent_seeds (bool): use different seeds for each picture //def: false",
|
||||
"scriptValues": "[false, false]"
|
||||
},
|
||||
"X/Y/Z plot": {
|
||||
"titleText": "Params:\nx_type (int): index of axis type (see below) //def: 3\nx_values (mixed, str) //def: \"0.00-0.99 [4]\"\ny_type (int) //def: 4\ny_values (mixed, str) //def: \"5-30 [4]\"\nz_type (int) //def: 5\nz_values (mixed, str) //def: \"2.5-12.5 [4]\"\ndraw_legend (bool): return grid of all images //def: false\ninclude_lone_images (bool): return individual images //def: true\ninclude_subgrids (bool) //def: false\nno_fixed_seeds (bool): use different seeds for each picture //def: false\n\nAvailable axis types:\n0: Nothing\n1: Seed\n2: Var. seed\n3: Var. strength\n4: Steps\n5: Hires steps (txt2img only)\n6: CFG Scale\n7: Prompt S/R\n8: Prompt order\n9: Sampler (txt2img only)\n10: Sampler (img2img only)\n11: Checkpoint Name\n12: Sigma Churn\n13: Sigma min\n14: Sigma max\n15: Sigma noise\n16: Eta\n17: Clip skip\n18: Denoising\n19: Hires upscaler (txt2img only)\n20: Cond. Image Mask Weight (img2img only)\n21: VAE\n22: Styles",
|
||||
"scriptValues": "[3, \"0.00-0.99 [4]\", 4, \"5-30 [4]\", 6, \"2.5-12.5 [4]\", false, true, false, false]"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -371,13 +371,6 @@
|
|||
<div id="script-select" class="script-select">
|
||||
<select id="script-selector" onchange="changeScript(event)">
|
||||
<option id="no_selected_script" value="">Select a script...</option>
|
||||
<option id="loopback" value="Loopback">
|
||||
Loopback (img2img only)
|
||||
</option>
|
||||
<option id="prompt_matrix" value="Prompt matrix">
|
||||
Prompt Matrix
|
||||
</option>
|
||||
<option id="xy_plot" value="X/Y/Z plot">X/Y/Z plot</option>
|
||||
<option id="custom" value="custom">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
|
@ -454,7 +447,7 @@
|
|||
|
||||
<!-- Content -->
|
||||
<script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script>
|
||||
<script src="js/index.js?v=3642e58" type="text/javascript"></script>
|
||||
<script src="js/index.js?v=e87f7bf" type="text/javascript"></script>
|
||||
|
||||
<script
|
||||
src="js/ui/floating/history.js?v=4f29db4"
|
||||
|
|
86
js/index.js
86
js/index.js
|
@ -144,6 +144,7 @@ var host = "";
|
|||
var url = "/sdapi/v1/";
|
||||
const basePixelCount = 64; //64 px - ALWAYS 64 PX
|
||||
var focused = true;
|
||||
let defaultScripts = {};
|
||||
|
||||
function startup() {
|
||||
testHostConfiguration();
|
||||
|
@ -170,6 +171,7 @@ function startup() {
|
|||
changeRestoreFaces();
|
||||
changeSyncCursorSize();
|
||||
checkFocus();
|
||||
loadDefaultScripts();
|
||||
}
|
||||
|
||||
function setFixedHost(h, changePromptMessage) {
|
||||
|
@ -1358,6 +1360,19 @@ function checkFocus() {
|
|||
}
|
||||
}
|
||||
|
||||
async function loadDefaultScripts() {
|
||||
selector = document.getElementById("script-selector");
|
||||
const response = await fetch("./defaultscripts.json");
|
||||
const json = await response.json();
|
||||
for (const key in json.defaultScripts) {
|
||||
var opt = document.createElement("option");
|
||||
opt.value = opt.innerHTML = key;
|
||||
selector.appendChild(opt);
|
||||
}
|
||||
defaultScripts = json;
|
||||
//return json;
|
||||
}
|
||||
|
||||
function changeScript(evt) {
|
||||
let enable = () => {
|
||||
scriptName.disabled = false;
|
||||
|
@ -1371,63 +1386,6 @@ function changeScript(evt) {
|
|||
scriptName.value = selected;
|
||||
disable();
|
||||
switch (selected) {
|
||||
case "Loopback": {
|
||||
scriptArgs.value = "[8, 0.99]";
|
||||
scriptArgs.title =
|
||||
"Params:\n" +
|
||||
"loops (int) //def: 8\n" +
|
||||
"denoising_strength_change_factor (decimal, 0.90-1.10) //def: 0.99";
|
||||
break;
|
||||
}
|
||||
case "Prompt matrix": {
|
||||
scriptArgs.value = "[false, false]";
|
||||
scriptArgs.title =
|
||||
"Params:\n" +
|
||||
"put_at_start (bool): expect pipe (|) delimited options at start of prompt //def: false\n" +
|
||||
"different_seeds (bool): use different seeds for each picture //def: false";
|
||||
break;
|
||||
}
|
||||
case "X/Y/Z plot": {
|
||||
scriptArgs.value =
|
||||
'[3, "0.00-0.99 [4]", 4, "5-30 [4]", 6, "2.5-12.5 [4]", false, true, false, false]';
|
||||
scriptArgs.title =
|
||||
"Params:\n" +
|
||||
"x_type (int): index of axis type (see below) //def: 3\n" +
|
||||
'x_values (mixed, str) //def: "0.00-0.99 [4]"\n' +
|
||||
"y_type (int) //def: 4\n" +
|
||||
'y_values (mixed, str) //def: "5-30 [4]"\n' +
|
||||
"z_type (int) //def: 5\n" +
|
||||
'z_values (mixed, str) //def: "2.5-12.5 [4]"\n' +
|
||||
"draw_legend (bool): return grid of all images //def: false\n" +
|
||||
"include_lone_images (bool): return individual images //def: true\n" +
|
||||
"include_subgrids (bool) //def: false\n" +
|
||||
"no_fixed_seeds (bool): use different seeds for each picture //def: false\n\n" +
|
||||
"Available axis types:\n" +
|
||||
"0: Nothing\n" +
|
||||
"1: Seed\n" +
|
||||
"2: Var. seed\n" +
|
||||
"3: Var. strength\n" +
|
||||
"4: Steps\n" +
|
||||
"5: Hires steps (txt2img only)\n" +
|
||||
"6: CFG Scale\n" +
|
||||
"7: Prompt S/R\n" +
|
||||
"8: Prompt order\n" +
|
||||
"9: Sampler (txt2img only)\n" +
|
||||
"10: Sampler (img2img only)\n" +
|
||||
"11: Checkpoint Name\n" +
|
||||
"12: Sigma Churn\n" +
|
||||
"13: Sigma min\n" +
|
||||
"14: Sigma max\n" +
|
||||
"15: Sigma noise\n" +
|
||||
"16: Eta\n" +
|
||||
"17: Clip skip\n" +
|
||||
"18: Denoising\n" +
|
||||
"19: Hires upscaler (txt2img only)\n" +
|
||||
"20: Cond. Image Mask Weight (img2img only)\n" +
|
||||
"21: VAE\n" +
|
||||
"22: Styles";
|
||||
break;
|
||||
}
|
||||
case "custom": {
|
||||
scriptName.value = "";
|
||||
scriptArgs.value = "";
|
||||
|
@ -1435,10 +1393,20 @@ function changeScript(evt) {
|
|||
enable();
|
||||
break;
|
||||
}
|
||||
case "":
|
||||
default: {
|
||||
case "": {
|
||||
// specifically no selected script
|
||||
scriptArgs.value = "";
|
||||
scriptArgs.title = "";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// check defaultScripts objects for selected script
|
||||
scriptName.value = selected;
|
||||
scriptArgs.value = defaultScripts.defaultScripts[selected].scriptValues;
|
||||
scriptArgs.title = defaultScripts.defaultScripts[selected].titleText;
|
||||
// if not found, check user scripts
|
||||
|
||||
// if not found, wtf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
6
userdefinedscripts.json
Normal file
6
userdefinedscripts.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"userScript1": {
|
||||
"title": "template",
|
||||
"scriptValues": "[1, 0.999, true, \"4-10 [3]\", \"test text\"]"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue