mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Merge pull request #5644 from ThereforeGames/master
Improve img2img color correction by performing a luminosity blend
This commit is contained in:
commit
b81fa1e7f1
@ -27,6 +27,7 @@ from ldm.data.util import AddMiDaS
|
|||||||
from ldm.models.diffusion.ddpm import LatentDepth2ImageDiffusion
|
from ldm.models.diffusion.ddpm import LatentDepth2ImageDiffusion
|
||||||
|
|
||||||
from einops import repeat, rearrange
|
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.
|
# 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
|
opt_C = 4
|
||||||
@ -39,17 +40,19 @@ def setup_color_correction(image):
|
|||||||
return correction_target
|
return correction_target
|
||||||
|
|
||||||
|
|
||||||
def apply_color_correction(correction, image):
|
def apply_color_correction(correction, original_image):
|
||||||
logging.info("Applying color correction.")
|
logging.info("Applying color correction.")
|
||||||
image = Image.fromarray(cv2.cvtColor(exposure.match_histograms(
|
image = Image.fromarray(cv2.cvtColor(exposure.match_histograms(
|
||||||
cv2.cvtColor(
|
cv2.cvtColor(
|
||||||
np.asarray(image),
|
np.asarray(original_image),
|
||||||
cv2.COLOR_RGB2LAB
|
cv2.COLOR_RGB2LAB
|
||||||
),
|
),
|
||||||
correction,
|
correction,
|
||||||
channel_axis=2
|
channel_axis=2
|
||||||
), cv2.COLOR_LAB2RGB).astype("uint8"))
|
), cv2.COLOR_LAB2RGB).astype("uint8"))
|
||||||
|
|
||||||
|
image = blendLayers(image, original_image, BlendType.LUMINOSITY)
|
||||||
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
aenum
|
||||||
|
blendmodes
|
||||||
accelerate
|
accelerate
|
||||||
basicsr
|
basicsr
|
||||||
fairscale==0.4.4
|
fairscale==0.4.4
|
||||||
|
Loading…
Reference in New Issue
Block a user