mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
157 lines
5.1 KiB
HTML
157 lines
5.1 KiB
HTML
<html>
|
|
<head>
|
|
<title>Stable Diffusion WebUI</title>
|
|
<link rel="icon" href="data:,">
|
|
<style>
|
|
* {
|
|
font-family: 'Arial';
|
|
}
|
|
#header {
|
|
text-decoration: dotted underline;
|
|
}
|
|
#search {
|
|
margin-top: 20vh;
|
|
text-align: center;
|
|
}
|
|
fieldset {
|
|
border: none;
|
|
}
|
|
#prompt {
|
|
width: 500px;
|
|
border-radius: 20px 0px 0px 20px;
|
|
padding: 5px 10px 5px 10px;
|
|
border: 1px solid black;
|
|
outline: none;
|
|
}
|
|
#submit {
|
|
border-radius: 0px 20px 20px 0px;
|
|
padding: 5px 10px 5px 10px;
|
|
border: 1px solid black;
|
|
}
|
|
#results {
|
|
text-align: center;
|
|
padding-left: 20vw;
|
|
padding-right: 20vw;
|
|
padding-top: 10px;
|
|
}
|
|
img {
|
|
cursor: pointer;
|
|
height: 30vh;
|
|
border-radius: 5px;
|
|
margin: 10px;
|
|
}
|
|
input[type="number"] {
|
|
width: 60px;
|
|
}
|
|
#seed {
|
|
width: 150px;
|
|
}
|
|
</style>
|
|
<script>
|
|
function append_output(output) {
|
|
let output_node = document.createElement("img");
|
|
output_node.src = output[0];
|
|
|
|
let alt_text = output[1].toString() + " | " + output[2];
|
|
output_node.alt = alt_text;
|
|
output_node.title = alt_text;
|
|
// Update seed on click
|
|
output_node.addEventListener('click', () => {
|
|
document.querySelector("#seed").value = output[1];
|
|
});
|
|
|
|
document.querySelector("#results").prepend(output_node);
|
|
}
|
|
|
|
function append_outputs(outputs) {
|
|
for (const output of outputs) {
|
|
append_output(output);
|
|
}
|
|
}
|
|
|
|
function save_fields(form) {
|
|
for (const [k, v] of new FormData(form)) {
|
|
localStorage.setItem(k, v);
|
|
}
|
|
}
|
|
function load_fields(form) {
|
|
for (const [k, v] of new FormData(form)) {
|
|
const item = localStorage.getItem(k);
|
|
if (item != null) {
|
|
form.querySelector(`*[name=${k}]`).value = item;
|
|
}
|
|
}
|
|
}
|
|
|
|
window.onload = () => {
|
|
document.querySelector("#generate_form").addEventListener('submit', (e) => {
|
|
e.preventDefault();
|
|
const form = e.target;
|
|
const prompt = document.querySelector("#prompt").value;
|
|
|
|
// Post as JSON
|
|
fetch(form.action, {
|
|
method: form.method,
|
|
body: JSON.stringify(Object.fromEntries(new FormData(form))),
|
|
}).then((result) => {
|
|
result.json().then((data) => {
|
|
// Re-enable form, remove no-results-message
|
|
form.querySelector('fieldset').removeAttribute('disabled');
|
|
document.querySelector("#prompt").value = prompt;
|
|
|
|
if (data.outputs.length != 0) {
|
|
document.querySelector("#no_results_message")?.remove();
|
|
append_outputs(data.outputs);
|
|
} else {
|
|
alert("Error occurred while generating.");
|
|
}
|
|
});
|
|
});
|
|
|
|
// Disable form
|
|
form.querySelector('fieldset').setAttribute('disabled','');
|
|
document.querySelector("#prompt").value = `Generating: "${prompt}"`;
|
|
});
|
|
document.querySelector("#generate_form").addEventListener('change', (e) => {
|
|
save_fields(e.target.form);
|
|
});
|
|
load_fields(document.querySelector("#generate_form"));
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="search">
|
|
<h2 id="header">Stable Diffusion</h2>
|
|
|
|
<form id="generate_form" method="post" action="#">
|
|
<fieldset>
|
|
<input type="text" id="prompt" name="prompt">
|
|
<input type="submit" id="submit" value="Generate">
|
|
</fieldset>
|
|
<fieldset>
|
|
<label for="batch">Batch Size:</label>
|
|
<input value="1" type="number" id="batch" name="batch">
|
|
<label for="steps">Steps:</label>
|
|
<input value="50" type="number" id="steps" name="steps">
|
|
<label for="cfgscale">Cfg Scale:</label>
|
|
<input value="7.5" type="number" id="cfgscale" name="cfgscale" step="any">
|
|
<span>•</span>
|
|
<label title="Set to multiple of 64" for="width">Width:</label>
|
|
<input value="512" type="number" id="width" name="width">
|
|
<label title="Set to multiple of 64" for="height">Height:</label>
|
|
<input value="512" type="number" id="height" name="height">
|
|
<span>•</span>
|
|
<label title="Set to -1 for random seed" for="seed">Seed:</label>
|
|
<input value="-1" type="number" id="seed" name="seed">
|
|
</fieldset>
|
|
</form>
|
|
</div>
|
|
<hr style="width: 200px">
|
|
<div id="results">
|
|
<div id="no_results_message">
|
|
<i><p>No results...</p></i>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|