diff options
author | EyeDeck <eyedeck@gmail.com> | 2022-09-11 22:15:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-11 22:15:30 +0000 |
commit | e05e46aa3f3b2230affe399372ad96d8736e4010 (patch) | |
tree | e51f423443ad2fd77da2c4b9f3c6d25f563fca66 /modules/processing.py | |
parent | 29a2933e23e68900bbae741a98439d0c9d6f26f6 (diff) | |
parent | 303b75c1490e8f9e146ba207f3425a7f0317cb12 (diff) | |
download | stable-diffusion-webui-gfx803-e05e46aa3f3b2230affe399372ad96d8736e4010.tar.gz stable-diffusion-webui-gfx803-e05e46aa3f3b2230affe399372ad96d8736e4010.tar.bz2 stable-diffusion-webui-gfx803-e05e46aa3f3b2230affe399372ad96d8736e4010.zip |
Merge branch 'master' into master
Diffstat (limited to 'modules/processing.py')
-rw-r--r-- | modules/processing.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/modules/processing.py b/modules/processing.py index cf2e13d3..7dc2b9af 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -10,6 +10,7 @@ from PIL import Image, ImageFilter, ImageOps import random
import modules.sd_hijack
+from modules import devices
from modules.sd_hijack import model_hijack
from modules.sd_samplers import samplers, samplers_for_img2img
from modules.shared import opts, cmd_opts, state
@@ -23,11 +24,6 @@ opt_C = 4 opt_f = 8
-def torch_gc():
- if torch.cuda.is_available():
- torch.cuda.empty_cache()
- torch.cuda.ipc_collect()
-
class StableDiffusionProcessing:
def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prompt="", prompt_style="None", seed=-1, subseed=-1, subseed_strength=0, seed_resize_from_h=-1, seed_resize_from_w=-1, sampler_index=0, batch_size=1, n_iter=1, steps=50, cfg_scale=7.0, width=512, height=512, restore_faces=False, tiling=False, do_not_save_samples=False, do_not_save_grid=False, extra_generation_params=None, overlay_images=None, negative_prompt=None):
@@ -157,7 +153,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed: """this is the main loop that both txt2img and img2img use; it calls func_init once inside all the scopes and func_sample once per batch"""
assert p.prompt is not None
- torch_gc()
+ devices.torch_gc()
fix_seed(p)
@@ -258,7 +254,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed: x_sample = x_sample.astype(np.uint8)
if p.restore_faces:
- torch_gc()
+ devices.torch_gc()
x_sample = modules.face_restoration.restore_faces(x_sample)
@@ -279,7 +275,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed: image = image.convert('RGB')
if opts.samples_save and not p.do_not_save_samples:
- images.save_image(image, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i))
+ images.save_image(image, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i), process_info = Processed(p, output_images, all_seeds[0], infotext()))
output_images.append(image)
@@ -297,7 +293,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed: if opts.grid_save:
images.save_image(grid, p.outpath_grids, "grid", all_seeds[0], all_prompts[0], opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename)
- torch_gc()
+ devices.torch_gc()
return Processed(p, output_images, all_seeds[0], infotext())
|