mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge pull request #178 from lstein/dream-web-upscaling
FEAT: Dream web upscaling
This commit is contained in:
commit
7718af041c
@ -46,6 +46,9 @@ class DreamServer(BaseHTTPRequestHandler):
|
|||||||
height = int(post_data['height'])
|
height = int(post_data['height'])
|
||||||
cfgscale = float(post_data['cfgscale'])
|
cfgscale = float(post_data['cfgscale'])
|
||||||
gfpgan_strength = float(post_data['gfpgan_strength'])
|
gfpgan_strength = float(post_data['gfpgan_strength'])
|
||||||
|
upscale_level = post_data['upscale_level']
|
||||||
|
upscale_strength = post_data['upscale_strength']
|
||||||
|
upscale = [int(upscale_level),float(upscale_strength)] if upscale_level != '' else None
|
||||||
seed = None if int(post_data['seed']) == -1 else int(post_data['seed'])
|
seed = None if int(post_data['seed']) == -1 else int(post_data['seed'])
|
||||||
|
|
||||||
print(f"Request to generate with prompt: {prompt}")
|
print(f"Request to generate with prompt: {prompt}")
|
||||||
@ -60,7 +63,9 @@ class DreamServer(BaseHTTPRequestHandler):
|
|||||||
height = height,
|
height = height,
|
||||||
seed = seed,
|
seed = seed,
|
||||||
steps = steps,
|
steps = steps,
|
||||||
gfpgan_strength = gfpgan_strength)
|
gfpgan_strength = gfpgan_strength,
|
||||||
|
upscale = upscale
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# Decode initimg as base64 to temp file
|
# Decode initimg as base64 to temp file
|
||||||
with open("./img2img-tmp.png", "wb") as f:
|
with open("./img2img-tmp.png", "wb") as f:
|
||||||
@ -74,7 +79,9 @@ class DreamServer(BaseHTTPRequestHandler):
|
|||||||
cfg_scale = cfgscale,
|
cfg_scale = cfgscale,
|
||||||
seed = seed,
|
seed = seed,
|
||||||
gfpgan_strength=gfpgan_strength,
|
gfpgan_strength=gfpgan_strength,
|
||||||
steps = steps)
|
upscale = upscale,
|
||||||
|
steps = steps
|
||||||
|
)
|
||||||
# Remove the temp file
|
# Remove the temp file
|
||||||
os.remove("./img2img-tmp.png")
|
os.remove("./img2img-tmp.png")
|
||||||
|
|
||||||
|
@ -32,6 +32,9 @@ fieldset {
|
|||||||
padding: 5px 10px 5px 10px;
|
padding: 5px 10px 5px 10px;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
|
#reset-all {
|
||||||
|
background-color: pink;
|
||||||
|
}
|
||||||
#results {
|
#results {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
max-width: 1000px;
|
max-width: 1000px;
|
||||||
|
@ -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>•</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" selected>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,9 +62,20 @@
|
|||||||
<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>
|
||||||
|
<button type="button" id="reset-all">Reset to Defaults</button>
|
||||||
<br>
|
<br>
|
||||||
<label title="Strength of the gfpgan algorithm ex: '1', --gfpgan startup flag is required." for="gfpgan_strength">GPFGAN Strength:</label>
|
<p><em>The options below require the GFPGAN and ESRGAN packages to be installed</em></p>
|
||||||
<input value="0.75" min="0" max="1" type="number" id="gfpgan_strength" name="gfpgan_strength" step="0.01">
|
<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">
|
||||||
|
<label title="Upscaling to perform using ESRGAN." for="upscale_level">Upscaling Level</label>
|
||||||
|
<select id="upscale_level" name="upscale_level" value="">
|
||||||
|
<option value="" selected></option>
|
||||||
|
<option value="2">2x</option>
|
||||||
|
<option value="4">4x</option>
|
||||||
|
</select>
|
||||||
|
<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">
|
||||||
</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>
|
||||||
|
@ -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()
|
||||||
|
location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
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"));
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user