added reset to defaults button and sampler selection

This commit is contained in:
Lincoln Stein 2022-08-28 21:35:52 -04:00
parent 22365a3f12
commit e2ae6d288d
3 changed files with 26 additions and 5 deletions

View File

@ -48,7 +48,7 @@ img {
line-height:2em; line-height:2em;
} }
input[type="number"] { input[type="number"] {
width: 60px; width: 30px;
} }
#seed { #seed {
width: 150px; width: 150px;

View File

@ -18,12 +18,22 @@
</fieldset> </fieldset>
<fieldset id="fieldset-config"> <fieldset id="fieldset-config">
<label for="iterations">Images to generate:</label> <label for="iterations">Images to generate:</label>
<input value="1" type="number" id="iterations" name="iterations"> <input value="1" type="number" id="iterations" name="iterations" size="4">
<label for="steps">Steps:</label> <label for="steps">Steps:</label>
<input value="50" type="number" id="steps" name="steps"> <input value="50" type="number" id="steps" name="steps">
<label for="cfgscale">Cfg Scale:</label> <label for="cfgscale">Cfg Scale:</label>
<input value="7.5" type="number" id="cfgscale" name="cfgscale" step="any"> <input value="7.5" type="number" id="cfgscale" name="cfgscale" step="any">
<span>&bull;</span> <label for="sampler">Sampler:</label>
<select id="sampler" name="sampler" value="k_lms">
<option value="ddim">DDIM</option>
<option value="plms">PLMS</option>
<option value="k_lms">KLMS</option>
<option value="k_dpm_2">KDPM_2</option>
<option value="k_dpm_2_a">KDPM_2A</option>
<option value="k_euler">KEULER</option>
<option value="k_heun">KHEUN</option>
</select>
<br>
<label title="Set to multiple of 64" for="width">Width:</label> <label title="Set to multiple of 64" for="width">Width:</label>
<select id="width" name="width" value="512"> <select id="width" name="width" value="512">
<option value="64">64</option> <option value="128">128</option> <option value="64">64</option> <option value="128">128</option>
@ -52,10 +62,12 @@
<label title="Set to -1 for random seed" for="seed">Seed:</label> <label title="Set to -1 for random seed" for="seed">Seed:</label>
<input value="-1" type="number" id="seed" name="seed"> <input value="-1" type="number" id="seed" name="seed">
<button type="button" id="reset">&olarr;</button> <button type="button" id="reset">&olarr;</button>
<span>&bull;</span>
<button type="button" id="reset-all">Reset to Defaults</button>
<br> <br>
<p><em>The options below require the GFPGAN and ESRGAN packages to be installed</em></p> <p><em>The options below require the GFPGAN and ESRGAN packages to be installed</em></p>
<label title="Strength of the gfpgan (face fixing) algorithm." for="gfpgan_strength">GPFGAN Strength:</label> <label title="Strength of the gfpgan (face fixing) algorithm." for="gfpgan_strength">GPFGAN Strength:</label>
<input value="0.8" min="0" max="1" type="number" id="gfpgan_strength" name="gfpgan_strength" step="0.1"> <input value="0.8" min="0" max="1" type="number" id="gfpgan_strength" name="gfpgan_strength" step="0.05">
<label title="Upscaling to perform using ESRGAN." for="upscaling">Upscaling Level</label> <label title="Upscaling to perform using ESRGAN." for="upscaling">Upscaling Level</label>
<select id="upscaling" name="upscaling" value=""> <select id="upscaling" name="upscaling" value="">
<option value=""></option> <option value=""></option>
@ -63,7 +75,7 @@
<option value="4">4x</option> <option value="4">4x</option>
</select> </select>
<label title="Strength of the esrgan (upscaling) algorithm." for="esrgan_strength">ESRGAN Strength:</label> <label title="Strength of the esrgan (upscaling) algorithm." for="esrgan_strength">ESRGAN Strength:</label>
<input value="0.75" min="0" max="1" type="number" id="esrgan_strength" name="esrgan_strength" step="0.1"> <input value="0.75" min="0" max="1" type="number" id="esrgan_strength" name="esrgan_strength" step="0.05">
</fieldset> </fieldset>
</form> </form>
<div id="about">For news and support for this web service, visit our <a href="http://github.com/lstein/stable-diffusion">GitHub site</a></div> <div id="about">For news and support for this web service, visit our <a href="http://github.com/lstein/stable-diffusion">GitHub site</a></div>

View File

@ -43,6 +43,7 @@ function saveFields(form) {
} }
} }
} }
function loadFields(form) { function loadFields(form) {
for (const [k, v] of new FormData(form)) { for (const [k, v] of new FormData(form)) {
const item = localStorage.getItem(k); const item = localStorage.getItem(k);
@ -52,6 +53,11 @@ function loadFields(form) {
} }
} }
function clearFields(form) {
localStorage.clear()
form.reset()
}
async function generateSubmit(form) { async function generateSubmit(form) {
const prompt = document.querySelector("#prompt").value; const prompt = document.querySelector("#prompt").value;
@ -97,5 +103,8 @@ window.onload = () => {
document.querySelector("#seed").value = -1; document.querySelector("#seed").value = -1;
saveFields(e.target.form); saveFields(e.target.form);
}); });
document.querySelector("#reset-all").addEventListener('click', (e) => {
clearFields(e.target.form);
});
loadFields(document.querySelector("#generate-form")); loadFields(document.querySelector("#generate-form"));
}; };