From c84e333622883be7f1c2efa08259d36d27cadec7 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Tue, 13 Sep 2022 12:51:57 +0300 Subject: color correction option for all img2img modes #363 --- modules/img2img.py | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'modules/img2img.py') diff --git a/modules/img2img.py b/modules/img2img.py index e3109121..70c99e33 100644 --- a/modules/img2img.py +++ b/modules/img2img.py @@ -1,5 +1,4 @@ import math -import cv2 import numpy as np from PIL import Image, ImageOps, ImageChops @@ -76,18 +75,7 @@ def img2img(prompt: str, negative_prompt: str, prompt_style: str, init_img, init state.job_count = n_iter - do_color_correction = False - try: - from skimage import exposure - do_color_correction = True - except: - print("Install scikit-image to perform color correction on loopback") - - for i in range(n_iter): - if do_color_correction and i == 0: - correction_target = cv2.cvtColor(np.asarray(init_img.copy()), cv2.COLOR_RGB2LAB) - p.n_iter = 1 p.batch_size = 1 p.do_not_save_grid = True @@ -101,16 +89,6 @@ def img2img(prompt: str, negative_prompt: str, prompt_style: str, init_img, init init_img = processed.images[0] - if do_color_correction and correction_target is not None: - init_img = Image.fromarray(cv2.cvtColor(exposure.match_histograms( - cv2.cvtColor( - np.asarray(init_img), - cv2.COLOR_RGB2LAB - ), - correction_target, - channel_axis=2 - ), cv2.COLOR_LAB2RGB).astype("uint8")) - p.init_images = [init_img] p.seed = processed.seed + 1 p.denoising_strength = min(max(p.denoising_strength * denoising_strength_change_factor, 0.1), 1) -- cgit v1.2.1