mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
use LF not CRLF for files, oh god
This commit is contained in:
parent
f695988915
commit
d9eab7f383
@ -1,69 +1,69 @@
|
|||||||
* {
|
* {
|
||||||
font-family: 'Arial';
|
font-family: 'Arial';
|
||||||
}
|
}
|
||||||
#header {
|
#header {
|
||||||
text-decoration: dotted underline;
|
text-decoration: dotted underline;
|
||||||
}
|
}
|
||||||
#search {
|
#search {
|
||||||
margin-top: 20vh;
|
margin-top: 20vh;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
fieldset {
|
fieldset {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
#fieldset-search {
|
#fieldset-search {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
#scaling-inprocess-message{
|
#scaling-inprocess-message{
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#prompt {
|
#prompt {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|
||||||
border-radius: 20px 0px 0px 20px;
|
border-radius: 20px 0px 0px 20px;
|
||||||
padding: 5px 10px 5px 10px;
|
padding: 5px 10px 5px 10px;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
border-right: none;
|
border-right: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
#submit {
|
#submit {
|
||||||
border-radius: 0px 20px 20px 0px;
|
border-radius: 0px 20px 20px 0px;
|
||||||
padding: 5px 10px 5px 10px;
|
padding: 5px 10px 5px 10px;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
#reset-all {
|
#reset-all {
|
||||||
background-color: pink;
|
background-color: pink;
|
||||||
}
|
}
|
||||||
#results {
|
#results {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
height: 30vh;
|
height: 30vh;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
#fieldset-config {
|
#fieldset-config {
|
||||||
line-height:2em;
|
line-height:2em;
|
||||||
}
|
}
|
||||||
input[type="number"] {
|
input[type="number"] {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
}
|
}
|
||||||
#seed {
|
#seed {
|
||||||
width: 150px;
|
width: 150px;
|
||||||
}
|
}
|
||||||
hr {
|
hr {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
label {
|
label {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
@ -1,94 +1,94 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Stable Diffusion Dream Server</title>
|
<title>Stable Diffusion Dream Server</title>
|
||||||
<link rel="icon" href="data:,">
|
<link rel="icon" href="data:,">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
<link rel="stylesheet" href="static/dream_web/index.css">
|
<link rel="stylesheet" href="static/dream_web/index.css">
|
||||||
<script src="static/dream_web/index.js"></script>
|
<script src="static/dream_web/index.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="search">
|
<div id="search">
|
||||||
<h2 id="header">Stable Diffusion Dream Server</h2>
|
<h2 id="header">Stable Diffusion Dream Server</h2>
|
||||||
|
|
||||||
<form id="generate-form" method="post" action="#">
|
<form id="generate-form" method="post" action="#">
|
||||||
<fieldset id="fieldset-search">
|
<fieldset id="fieldset-search">
|
||||||
<input type="text" id="prompt" name="prompt">
|
<input type="text" id="prompt" name="prompt">
|
||||||
<input type="submit" id="submit" value="Generate">
|
<input type="submit" id="submit" value="Generate">
|
||||||
</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" size="4">
|
<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">
|
||||||
<label for="sampler">Sampler:</label>
|
<label for="sampler">Sampler:</label>
|
||||||
<select id="sampler" name="sampler" value="k_lms">
|
<select id="sampler" name="sampler" value="k_lms">
|
||||||
<option value="ddim">DDIM</option>
|
<option value="ddim">DDIM</option>
|
||||||
<option value="plms">PLMS</option>
|
<option value="plms">PLMS</option>
|
||||||
<option value="k_lms" selected>KLMS</option>
|
<option value="k_lms" selected>KLMS</option>
|
||||||
<option value="k_dpm_2">KDPM_2</option>
|
<option value="k_dpm_2">KDPM_2</option>
|
||||||
<option value="k_dpm_2_a">KDPM_2A</option>
|
<option value="k_dpm_2_a">KDPM_2A</option>
|
||||||
<option value="k_euler">KEULER</option>
|
<option value="k_euler">KEULER</option>
|
||||||
<option value="k_heun">KHEUN</option>
|
<option value="k_heun">KHEUN</option>
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<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>
|
||||||
<option value="192">192</option> <option value="256">256</option>
|
<option value="192">192</option> <option value="256">256</option>
|
||||||
<option value="320">320</option> <option value="384">384</option>
|
<option value="320">320</option> <option value="384">384</option>
|
||||||
<option value="448">448</option> <option value="512" selected>512</option>
|
<option value="448">448</option> <option value="512" selected>512</option>
|
||||||
<option value="576">576</option> <option value="640">640</option>
|
<option value="576">576</option> <option value="640">640</option>
|
||||||
<option value="704">704</option> <option value="768">768</option>
|
<option value="704">704</option> <option value="768">768</option>
|
||||||
<option value="832">832</option> <option value="896">896</option>
|
<option value="832">832</option> <option value="896">896</option>
|
||||||
<option value="960">960</option> <option value="1024">1024</option>
|
<option value="960">960</option> <option value="1024">1024</option>
|
||||||
</select>
|
</select>
|
||||||
<label title="Set to multiple of 64" for="height">Height:</label>
|
<label title="Set to multiple of 64" for="height">Height:</label>
|
||||||
<select id="height" name="height" value="512">
|
<select id="height" name="height" value="512">
|
||||||
<option value="64">64</option> <option value="128">128</option>
|
<option value="64">64</option> <option value="128">128</option>
|
||||||
<option value="192">192</option> <option value="256">256</option>
|
<option value="192">192</option> <option value="256">256</option>
|
||||||
<option value="320">320</option> <option value="384">384</option>
|
<option value="320">320</option> <option value="384">384</option>
|
||||||
<option value="448">448</option> <option value="512" selected>512</option>
|
<option value="448">448</option> <option value="512" selected>512</option>
|
||||||
<option value="576">576</option> <option value="640">640</option>
|
<option value="576">576</option> <option value="640">640</option>
|
||||||
<option value="704">704</option> <option value="768">768</option>
|
<option value="704">704</option> <option value="768">768</option>
|
||||||
<option value="832">832</option> <option value="896">896</option>
|
<option value="832">832</option> <option value="896">896</option>
|
||||||
<option value="960">960</option> <option value="1024">1024</option>
|
<option value="960">960</option> <option value="1024">1024</option>
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<br>
|
||||||
<label title="Upload an image to use img2img" for="initimg">Img2Img Init:</label>
|
<label title="Upload an image to use img2img" for="initimg">Img2Img Init:</label>
|
||||||
<input type="file" id="initimg" name="initimg" accept=".jpg, .jpeg, .png">
|
<input type="file" id="initimg" name="initimg" accept=".jpg, .jpeg, .png">
|
||||||
<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">↺</button>
|
<button type="button" id="reset">↺</button>
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<button type="button" id="reset-all">Reset to Defaults</button>
|
<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.05">
|
<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="upscale_level">Upscaling Level</label>
|
<label title="Upscaling to perform using ESRGAN." for="upscale_level">Upscaling Level</label>
|
||||||
<select id="upscale_level" name="upscale_level" value="">
|
<select id="upscale_level" name="upscale_level" value="">
|
||||||
<option value="" selected></option>
|
<option value="" selected></option>
|
||||||
<option value="2">2x</option>
|
<option value="2">2x</option>
|
||||||
<option value="4">4x</option>
|
<option value="4">4x</option>
|
||||||
</select>
|
</select>
|
||||||
<label title="Strength of the esrgan (upscaling) algorithm." for="upscale_strength">Upscale Strength:</label>
|
<label title="Strength of the esrgan (upscaling) algorithm." for="upscale_strength">Upscale Strength:</label>
|
||||||
<input value="0.75" min="0" max="1" type="number" id="upscale_strength" name="upscale_strength" step="0.05">
|
<input value="0.75" min="0" max="1" type="number" id="upscale_strength" name="upscale_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>
|
||||||
<br>
|
<br>
|
||||||
<progress id="progress" value="0" max="1"></progress>
|
<progress id="progress" value="0" max="1"></progress>
|
||||||
<div id="scaling-inprocess-message">
|
<div id="scaling-inprocess-message">
|
||||||
<i><span>Postprocessing...</span><span id="processing_cnt">1/3</span></i>
|
<i><span>Postprocessing...</span><span id="processing_cnt">1/3</span></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="results">
|
<div id="results">
|
||||||
<div id="no-results-message">
|
<div id="no-results-message">
|
||||||
<i><p>No results...</p></i>
|
<i><p>No results...</p></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,127 +1,127 @@
|
|||||||
function toBase64(file) {
|
function toBase64(file) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const r = new FileReader();
|
const r = new FileReader();
|
||||||
r.readAsDataURL(file);
|
r.readAsDataURL(file);
|
||||||
r.onload = () => resolve(r.result);
|
r.onload = () => resolve(r.result);
|
||||||
r.onerror = (error) => reject(error);
|
r.onerror = (error) => reject(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendOutput(src, seed, config) {
|
function appendOutput(src, seed, config) {
|
||||||
let outputNode = document.createElement("img");
|
let outputNode = document.createElement("img");
|
||||||
outputNode.src = src;
|
outputNode.src = src;
|
||||||
|
|
||||||
let altText = seed.toString() + " | " + config.prompt;
|
let altText = seed.toString() + " | " + config.prompt;
|
||||||
outputNode.alt = altText;
|
outputNode.alt = altText;
|
||||||
outputNode.title = altText;
|
outputNode.title = altText;
|
||||||
|
|
||||||
// Reload image config
|
// Reload image config
|
||||||
outputNode.addEventListener('click', () => {
|
outputNode.addEventListener('click', () => {
|
||||||
let form = document.querySelector("#generate-form");
|
let form = document.querySelector("#generate-form");
|
||||||
for (const [k, v] of new FormData(form)) {
|
for (const [k, v] of new FormData(form)) {
|
||||||
form.querySelector(`*[name=${k}]`).value = config[k];
|
form.querySelector(`*[name=${k}]`).value = config[k];
|
||||||
}
|
}
|
||||||
document.querySelector("#seed").value = seed;
|
document.querySelector("#seed").value = seed;
|
||||||
|
|
||||||
saveFields(document.querySelector("#generate-form"));
|
saveFields(document.querySelector("#generate-form"));
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector("#results").prepend(outputNode);
|
document.querySelector("#results").prepend(outputNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveFields(form) {
|
function saveFields(form) {
|
||||||
for (const [k, v] of new FormData(form)) {
|
for (const [k, v] of new FormData(form)) {
|
||||||
if (typeof v !== 'object') { // Don't save 'file' type
|
if (typeof v !== 'object') { // Don't save 'file' type
|
||||||
localStorage.setItem(k, v);
|
localStorage.setItem(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
form.querySelector(`*[name=${k}]`).value = item;
|
form.querySelector(`*[name=${k}]`).value = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearFields(form) {
|
function clearFields(form) {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
location.reload()
|
location.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateSubmit(form) {
|
async function generateSubmit(form) {
|
||||||
const prompt = document.querySelector("#prompt").value;
|
const prompt = document.querySelector("#prompt").value;
|
||||||
|
|
||||||
// Convert file data to base64
|
// Convert file data to base64
|
||||||
let formData = Object.fromEntries(new FormData(form));
|
let formData = Object.fromEntries(new FormData(form));
|
||||||
formData.initimg = formData.initimg.name !== '' ? await toBase64(formData.initimg) : null;
|
formData.initimg = formData.initimg.name !== '' ? await toBase64(formData.initimg) : null;
|
||||||
|
|
||||||
document.querySelector('progress').setAttribute('max', formData.steps);
|
document.querySelector('progress').setAttribute('max', formData.steps);
|
||||||
|
|
||||||
// Post as JSON, using Fetch streaming to get results
|
// Post as JSON, using Fetch streaming to get results
|
||||||
fetch(form.action, {
|
fetch(form.action, {
|
||||||
method: form.method,
|
method: form.method,
|
||||||
body: JSON.stringify(formData),
|
body: JSON.stringify(formData),
|
||||||
}).then(async (response) => {
|
}).then(async (response) => {
|
||||||
const reader = response.body.getReader();
|
const reader = response.body.getReader();
|
||||||
|
|
||||||
let noOutputs = true;
|
let noOutputs = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
let {value, done} = await reader.read();
|
let {value, done} = await reader.read();
|
||||||
value = new TextDecoder().decode(value);
|
value = new TextDecoder().decode(value);
|
||||||
if (done) break;
|
if (done) break;
|
||||||
|
|
||||||
for (let event of value.split('\n').filter(e => e !== '')) {
|
for (let event of value.split('\n').filter(e => e !== '')) {
|
||||||
const data = JSON.parse(event);
|
const data = JSON.parse(event);
|
||||||
|
|
||||||
if (data.event == 'result') {
|
if (data.event == 'result') {
|
||||||
noOutputs = false;
|
noOutputs = false;
|
||||||
document.querySelector("#no-results-message")?.remove();
|
document.querySelector("#no-results-message")?.remove();
|
||||||
appendOutput(data.files[0],data.files[1],data.config)
|
appendOutput(data.files[0],data.files[1],data.config)
|
||||||
} else if (data.event == 'upscaling-started') {
|
} else if (data.event == 'upscaling-started') {
|
||||||
document.getElementById("processing_cnt").textContent=data.processed_file_cnt;
|
document.getElementById("processing_cnt").textContent=data.processed_file_cnt;
|
||||||
document.getElementById("scaling-inprocess-message").style.display = "block";
|
document.getElementById("scaling-inprocess-message").style.display = "block";
|
||||||
} else if (data.event == 'upscaling-done') {
|
} else if (data.event == 'upscaling-done') {
|
||||||
document.getElementById("scaling-inprocess-message").style.display = "none";
|
document.getElementById("scaling-inprocess-message").style.display = "none";
|
||||||
} else if (data.event == 'step') {
|
} else if (data.event == 'step') {
|
||||||
document.querySelector('progress').setAttribute('value', data.step.toString());
|
document.querySelector('progress').setAttribute('value', data.step.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-enable form, remove no-results-message
|
// Re-enable form, remove no-results-message
|
||||||
form.querySelector('fieldset').removeAttribute('disabled');
|
form.querySelector('fieldset').removeAttribute('disabled');
|
||||||
document.querySelector("#prompt").value = prompt;
|
document.querySelector("#prompt").value = prompt;
|
||||||
document.querySelector('progress').setAttribute('value', '0');
|
document.querySelector('progress').setAttribute('value', '0');
|
||||||
|
|
||||||
if (noOutputs) {
|
if (noOutputs) {
|
||||||
alert("Error occurred while generating.");
|
alert("Error occurred while generating.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Disable form while generating
|
// Disable form while generating
|
||||||
form.querySelector('fieldset').setAttribute('disabled','');
|
form.querySelector('fieldset').setAttribute('disabled','');
|
||||||
document.querySelector("#prompt").value = `Generating: "${prompt}"`;
|
document.querySelector("#prompt").value = `Generating: "${prompt}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
document.querySelector("#generate-form").addEventListener('submit', (e) => {
|
document.querySelector("#generate-form").addEventListener('submit', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const form = e.target;
|
const form = e.target;
|
||||||
|
|
||||||
generateSubmit(form);
|
generateSubmit(form);
|
||||||
});
|
});
|
||||||
document.querySelector("#generate-form").addEventListener('change', (e) => {
|
document.querySelector("#generate-form").addEventListener('change', (e) => {
|
||||||
saveFields(e.target.form);
|
saveFields(e.target.form);
|
||||||
});
|
});
|
||||||
document.querySelector("#reset").addEventListener('click', (e) => {
|
document.querySelector("#reset").addEventListener('click', (e) => {
|
||||||
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) => {
|
document.querySelector("#reset-all").addEventListener('click', (e) => {
|
||||||
clearFields(e.target.form);
|
clearFields(e.target.form);
|
||||||
});
|
});
|
||||||
loadFields(document.querySelector("#generate-form"));
|
loadFields(document.querySelector("#generate-form"));
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user