mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-20 05:10:15 +08:00
Handle cleanup in case there's an exception thrown
This commit is contained in:
parent
74d001bc68
commit
3278887317
@ -323,19 +323,21 @@ class Api:
|
|||||||
|
|
||||||
with self.queue_lock:
|
with self.queue_lock:
|
||||||
p = StableDiffusionProcessingTxt2Img(sd_model=shared.sd_model, **args)
|
p = StableDiffusionProcessingTxt2Img(sd_model=shared.sd_model, **args)
|
||||||
p.scripts = script_runner
|
try:
|
||||||
p.outpath_grids = opts.outdir_txt2img_grids
|
p.scripts = script_runner
|
||||||
p.outpath_samples = opts.outdir_txt2img_samples
|
p.outpath_grids = opts.outdir_txt2img_grids
|
||||||
|
p.outpath_samples = opts.outdir_txt2img_samples
|
||||||
|
|
||||||
shared.state.begin()
|
shared.state.begin()
|
||||||
if selectable_scripts is not None:
|
if selectable_scripts is not None:
|
||||||
p.script_args = script_args
|
p.script_args = script_args
|
||||||
processed = scripts.scripts_txt2img.run(p, *p.script_args) # Need to pass args as list here
|
processed = scripts.scripts_txt2img.run(p, *p.script_args) # Need to pass args as list here
|
||||||
else:
|
else:
|
||||||
p.script_args = tuple(script_args) # Need to pass args as tuple here
|
p.script_args = tuple(script_args) # Need to pass args as tuple here
|
||||||
processed = process_images(p)
|
processed = process_images(p)
|
||||||
shared.state.end()
|
shared.state.end()
|
||||||
p.close()
|
finally:
|
||||||
|
p.close()
|
||||||
|
|
||||||
b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []
|
b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []
|
||||||
|
|
||||||
@ -380,20 +382,23 @@ class Api:
|
|||||||
|
|
||||||
with self.queue_lock:
|
with self.queue_lock:
|
||||||
p = StableDiffusionProcessingImg2Img(sd_model=shared.sd_model, **args)
|
p = StableDiffusionProcessingImg2Img(sd_model=shared.sd_model, **args)
|
||||||
p.init_images = [decode_base64_to_image(x) for x in init_images]
|
try:
|
||||||
p.scripts = script_runner
|
p.init_images = [decode_base64_to_image(x) for x in init_images]
|
||||||
p.outpath_grids = opts.outdir_img2img_grids
|
p.scripts = script_runner
|
||||||
p.outpath_samples = opts.outdir_img2img_samples
|
p.outpath_grids = opts.outdir_img2img_grids
|
||||||
|
p.outpath_samples = opts.outdir_img2img_samples
|
||||||
|
|
||||||
shared.state.begin()
|
shared.state.begin()
|
||||||
if selectable_scripts is not None:
|
if selectable_scripts is not None:
|
||||||
p.script_args = script_args
|
p.script_args = script_args
|
||||||
processed = scripts.scripts_img2img.run(p, *p.script_args) # Need to pass args as list here
|
processed = scripts.scripts_img2img.run(p, *p.script_args) # Need to pass args as list here
|
||||||
else:
|
else:
|
||||||
p.script_args = tuple(script_args) # Need to pass args as tuple here
|
p.script_args = tuple(script_args) # Need to pass args as tuple here
|
||||||
processed = process_images(p)
|
processed = process_images(p)
|
||||||
shared.state.end()
|
shared.state.end()
|
||||||
p.close()
|
|
||||||
|
finally:
|
||||||
|
p.close()
|
||||||
|
|
||||||
b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []
|
b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user