diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-12-24 06:17:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-24 06:17:40 +0000 |
commit | b81fa1e7f12f135533273225fc0c68d136ab9b93 (patch) | |
tree | e121d9aca2513d61ba6f7037ad94c713b9cc7dd1 | |
parent | 684d7059bcab0a198ec9c98ad7277cffe4bb2e17 (diff) | |
parent | 9bcf4165f89e6706a25ef0c32149d1fd3f4e102a (diff) | |
download | stable-diffusion-webui-gfx803-b81fa1e7f12f135533273225fc0c68d136ab9b93.tar.gz stable-diffusion-webui-gfx803-b81fa1e7f12f135533273225fc0c68d136ab9b93.tar.bz2 stable-diffusion-webui-gfx803-b81fa1e7f12f135533273225fc0c68d136ab9b93.zip |
Merge pull request #5644 from ThereforeGames/master
Improve img2img color correction by performing a luminosity blend
-rw-r--r-- | modules/processing.py | 9 | ||||
-rw-r--r-- | requirements.txt | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/modules/processing.py b/modules/processing.py index 24c537d1..bc841837 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -27,6 +27,7 @@ from ldm.data.util import AddMiDaS from ldm.models.diffusion.ddpm import LatentDepth2ImageDiffusion
from einops import repeat, rearrange
+from blendmodes.blend import blendLayers, BlendType
# some of those options should not be changed at all because they would break the model, so I removed them from options.
opt_C = 4
@@ -39,17 +40,19 @@ def setup_color_correction(image): return correction_target
-def apply_color_correction(correction, image):
+def apply_color_correction(correction, original_image):
logging.info("Applying color correction.")
image = Image.fromarray(cv2.cvtColor(exposure.match_histograms(
cv2.cvtColor(
- np.asarray(image),
+ np.asarray(original_image),
cv2.COLOR_RGB2LAB
),
correction,
channel_axis=2
), cv2.COLOR_LAB2RGB).astype("uint8"))
-
+
+ image = blendLayers(image, original_image, BlendType.LUMINOSITY)
+
return image
diff --git a/requirements.txt b/requirements.txt index 678acb4d..85e51575 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +aenum
+blendmodes
accelerate
basicsr
fairscale==0.4.4
|