mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-04 05:45:05 +08:00
actual solution to the uncommon hanging problem that is seemingly caused by multiple progress requests working on same tensor
This commit is contained in:
parent
d7c9c61420
commit
a459075d26
@ -95,31 +95,30 @@ def progressapi(req: ProgressRequest):
|
|||||||
predicted_duration = elapsed_since_start / progress if progress > 0 else None
|
predicted_duration = elapsed_since_start / progress if progress > 0 else None
|
||||||
eta = predicted_duration - elapsed_since_start if predicted_duration is not None else None
|
eta = predicted_duration - elapsed_since_start if predicted_duration is not None else None
|
||||||
|
|
||||||
|
live_preview = None
|
||||||
id_live_preview = req.id_live_preview
|
id_live_preview = req.id_live_preview
|
||||||
shared.state.set_current_image()
|
|
||||||
if opts.live_previews_enable and req.live_preview and shared.state.id_live_preview != req.id_live_preview:
|
|
||||||
image = shared.state.current_image
|
|
||||||
if image is not None:
|
|
||||||
buffered = io.BytesIO()
|
|
||||||
|
|
||||||
if opts.live_previews_image_format == "png":
|
if opts.live_previews_enable and req.live_preview:
|
||||||
# using optimize for large images takes an enormous amount of time
|
shared.state.set_current_image()
|
||||||
if max(*image.size) <= 256:
|
if shared.state.id_live_preview != req.id_live_preview:
|
||||||
save_kwargs = {"optimize": True}
|
image = shared.state.current_image
|
||||||
|
if image is not None:
|
||||||
|
buffered = io.BytesIO()
|
||||||
|
|
||||||
|
if opts.live_previews_image_format == "png":
|
||||||
|
# using optimize for large images takes an enormous amount of time
|
||||||
|
if max(*image.size) <= 256:
|
||||||
|
save_kwargs = {"optimize": True}
|
||||||
|
else:
|
||||||
|
save_kwargs = {"optimize": False, "compress_level": 1}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
save_kwargs = {"optimize": False, "compress_level": 1}
|
save_kwargs = {}
|
||||||
|
|
||||||
else:
|
image.save(buffered, format=opts.live_previews_image_format, **save_kwargs)
|
||||||
save_kwargs = {}
|
base64_image = base64.b64encode(buffered.getvalue()).decode('ascii')
|
||||||
|
live_preview = f"data:image/{opts.live_previews_image_format};base64,{base64_image}"
|
||||||
image.save(buffered, format=opts.live_previews_image_format, **save_kwargs)
|
id_live_preview = shared.state.id_live_preview
|
||||||
base64_image = base64.b64encode(buffered.getvalue()).decode('ascii')
|
|
||||||
live_preview = f"data:image/{opts.live_previews_image_format};base64,{base64_image}"
|
|
||||||
id_live_preview = shared.state.id_live_preview
|
|
||||||
else:
|
|
||||||
live_preview = None
|
|
||||||
else:
|
|
||||||
live_preview = None
|
|
||||||
|
|
||||||
return ProgressResponse(active=active, queued=queued, completed=completed, progress=progress, eta=eta, live_preview=live_preview, id_live_preview=id_live_preview, textinfo=shared.state.textinfo)
|
return ProgressResponse(active=active, queued=queued, completed=completed, progress=progress, eta=eta, live_preview=live_preview, id_live_preview=id_live_preview, textinfo=shared.state.textinfo)
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ def images_tensor_to_samples(image, approximation=None, model=None):
|
|||||||
|
|
||||||
|
|
||||||
def store_latent(decoded):
|
def store_latent(decoded):
|
||||||
state.current_latent = decoded.clone()
|
state.current_latent = decoded
|
||||||
|
|
||||||
if opts.live_previews_enable and opts.show_progress_every_n_steps > 0 and shared.state.sampling_step % opts.show_progress_every_n_steps == 0:
|
if opts.live_previews_enable and opts.show_progress_every_n_steps > 0 and shared.state.sampling_step % opts.show_progress_every_n_steps == 0:
|
||||||
if not shared.parallel_processing_allowed:
|
if not shared.parallel_processing_allowed:
|
||||||
|
@ -128,7 +128,7 @@ class State:
|
|||||||
devices.torch_gc()
|
devices.torch_gc()
|
||||||
|
|
||||||
def set_current_image(self):
|
def set_current_image(self):
|
||||||
"""sets self.current_image from self.current_latent if enough sampling steps have been made after the last call to this"""
|
"""if enough sampling steps have been made after the last call to this, sets self.current_image from self.current_latent, and modifies self.id_live_preview accordingly"""
|
||||||
if not shared.parallel_processing_allowed:
|
if not shared.parallel_processing_allowed:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user