diff --git a/ldm/dream/server.py b/ldm/dream/server.py index a13665cedc..2791a53d68 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -145,7 +145,7 @@ class DreamServer(BaseHTTPRequestHandler): step_writer.write_image(image, seed) # TODO PngWriter to return path url = step_writer.filepath self.wfile.write(bytes(json.dumps( - {'event':'step', 'step':step, 'url': url} + {'event':'step', 'step':step + 1, 'url': url} ) + '\n',"utf-8")) try: diff --git a/ldm/models/diffusion/ddim.py b/ldm/models/diffusion/ddim.py index 3d9086eb1d..3d90d53a3b 100644 --- a/ldm/models/diffusion/ddim.py +++ b/ldm/models/diffusion/ddim.py @@ -375,6 +375,7 @@ class DDIMSampler(object): x_latent, cond, t_start, + img_callback=None, unconditional_guidance_scale=1.0, unconditional_conditioning=None, use_original_steps=False, @@ -410,4 +411,7 @@ class DDIMSampler(object): unconditional_guidance_scale=unconditional_guidance_scale, unconditional_conditioning=unconditional_conditioning, ) + if img_callback: + img_callback(x_dec, i) + return x_dec diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index 7e44246f6b..58cf87a134 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -489,6 +489,7 @@ class T2I: z_enc, c, t_enc, + img_callback=callback, unconditional_guidance_scale=cfg_scale, unconditional_conditioning=uc, ) diff --git a/static/dream_web/index.js b/static/dream_web/index.js index 32175d0f22..5ef75a34a3 100644 --- a/static/dream_web/index.js +++ b/static/dream_web/index.js @@ -61,10 +61,13 @@ async function generateSubmit(form) { let formData = Object.fromEntries(new FormData(form)); formData.initimg = formData.initimg.name !== '' ? await toBase64(formData.initimg) : null; + let strength = 0.75; // TODO let this be specified in the UI + let totalSteps = formData.initimg ? Math.floor(.75 * formData.steps) : formData.steps; + let progressSectionEle = document.querySelector('#progress-section'); progressSectionEle.style.display = 'initial'; let progressEle = document.querySelector('#progress-bar'); - progressEle.setAttribute('max', formData.steps); + progressEle.setAttribute('max', totalSteps); let progressImageEle = document.querySelector('#progress-image'); progressImageEle.src = BLANK_IMAGE_URL; @@ -94,7 +97,7 @@ async function generateSubmit(form) { document.querySelector("#no-results-message")?.remove(); appendOutput(data.files[0],data.files[1],data.config); progressEle.setAttribute('value', 0); - progressEle.setAttribute('max', formData.steps); + progressEle.setAttribute('max', totalSteps); progressImageEle.src = BLANK_IMAGE_URL; } else if (data.event === 'upscaling-started') { document.getElementById("processing_cnt").textContent=data.processed_file_cnt;