working, but there is a bug in underlying txt2png() call that is preventing upscaled images from being returned

This commit is contained in:
Lincoln Stein 2022-08-28 22:42:31 -04:00
parent e2ae6d288d
commit 18899be4ae
4 changed files with 18 additions and 8 deletions

View File

@ -46,6 +46,9 @@ class DreamServer(BaseHTTPRequestHandler):
height = int(post_data['height'])
cfgscale = float(post_data['cfgscale'])
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'])
print(f"Request to generate with prompt: {prompt}")
@ -60,7 +63,9 @@ class DreamServer(BaseHTTPRequestHandler):
height = height,
seed = seed,
steps = steps,
gfpgan_strength = gfpgan_strength)
gfpgan_strength = gfpgan_strength,
upscale = upscale
)
else:
# Decode initimg as base64 to temp file
with open("./img2img-tmp.png", "wb") as f:
@ -74,7 +79,9 @@ class DreamServer(BaseHTTPRequestHandler):
cfg_scale = cfgscale,
seed = seed,
gfpgan_strength=gfpgan_strength,
steps = steps)
upscale = upscale,
steps = steps
)
# Remove the temp file
os.remove("./img2img-tmp.png")

View File

@ -32,6 +32,9 @@ fieldset {
padding: 5px 10px 5px 10px;
border: 1px solid black;
}
#reset-all {
background-color: pink;
}
#results {
text-align: center;
max-width: 1000px;
@ -48,7 +51,7 @@ img {
line-height:2em;
}
input[type="number"] {
width: 30px;
width: 60px;
}
#seed {
width: 150px;

View File

@ -68,14 +68,14 @@
<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>
<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>
<select id="upscaling" name="upscaling" value="">
<label title="Upscaling to perform using ESRGAN." for="upscale_level">Upscaling Level</label>
<select id="upscale_level" name="upscale_level" value="">
<option value=""></option>
<option value="2">2x</option>
<option value="4">4x</option>
</select>
<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.05">
<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>
</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>

View File

@ -55,7 +55,7 @@ function loadFields(form) {
function clearFields(form) {
localStorage.clear()
form.reset()
location.reload()
}
async function generateSubmit(form) {