From 8fb9c57ed62dcef721d50c1eeb9c20f65c509215 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 11 Sep 2022 23:24:24 +0300 Subject: add half() supporrt for CLIP interrogation --- modules/processing.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'modules/processing.py') diff --git a/modules/processing.py b/modules/processing.py index cf2e13d3..b1e8dad2 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) @@ -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()) -- cgit v1.2.3 From 4535239d8a2541171efe0af4bc55476e119f205e Mon Sep 17 00:00:00 2001 From: Michoko Date: Sun, 11 Sep 2022 17:17:13 +0200 Subject: Add a samples filename format option Adds a "samples filename format" option in the settings. This format can be defined by tags for maximum flexibility and scalability. --- modules/processing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/processing.py') diff --git a/modules/processing.py b/modules/processing.py index cf2e13d3..69e185af 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -279,7 +279,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) -- cgit v1.2.3