mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-01-23 18:54:34 +08:00
Merge pull request #422 from poipoi300/main
Minor ColorMatch improvement
This commit is contained in:
commit
7aafce8578
@ -98,6 +98,10 @@ https://github.com/hahnec/color-matcher/
|
||||
"""
|
||||
|
||||
def colormatch(self, image_ref, image_target, method, strength=1.0, multithread=True):
|
||||
# Skip unnecessary processing
|
||||
if strength == 0:
|
||||
return (image_target,)
|
||||
|
||||
try:
|
||||
from color_matcher import ColorMatcher
|
||||
except:
|
||||
@ -118,9 +122,12 @@ https://github.com/hahnec/color-matcher/
|
||||
image_target_np_i = images_target_np if batch_size == 1 else images_target[i].numpy()
|
||||
image_ref_np_i = image_ref_np if image_ref.size(0) == 1 else images_ref[i].numpy()
|
||||
try:
|
||||
image_result = cm.transfer(src=image_target_np_i, ref=image_ref_np_i, method=method)
|
||||
image_result = image_target_np_i + strength * (image_result - image_target_np_i)
|
||||
image_result = cm.transfer(src=image_target_np_i, ref=image_ref_np_i, method=method) # Avoid potential blur when only the fully color-matched image is used
|
||||
if strength != 1:
|
||||
image_result = image_target_np_i + strength * (image_result - image_target_np_i)
|
||||
|
||||
return torch.from_numpy(image_result)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Thread {i} error: {e}")
|
||||
return torch.from_numpy(image_target_np_i) # fallback
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user