rename color_correct_brightness&contrast.py to color_correct_brightness_and_contrast.py; color_correct_shadow&highlight.py to color_correct_shadow_and_highlight.py; rembg_ultra.py to rmbg_ultra.py; rembg_ultra_v2.py to rmbg_ultra.py

This commit is contained in:
chflame163
2024-06-27 09:37:44 +08:00
parent fc239893aa
commit 49004bb3d1
4 changed files with 59 additions and 59 deletions
@@ -1,60 +1,60 @@
from .imagefunc import *
NODE_NAME = 'Brightness & Contrast'
class ColorCorrectBrightnessAndContrast:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(self):
return {
"required": {
"image": ("IMAGE", ), #
"brightness": ("FLOAT", {"default": 1, "min": 0.0, "max": 3, "step": 0.01}),
"contrast": ("FLOAT", {"default": 1, "min": 0.0, "max": 3, "step": 0.01}),
"saturation": ("FLOAT", {"default": 1, "min": 0.0, "max": 3, "step": 0.01}),
},
"optional": {
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("image",)
FUNCTION = 'color_correct_brightness_and_contrast'
CATEGORY = '😺dzNodes/LayerColor'
def color_correct_brightness_and_contrast(self, image, brightness, contrast, saturation):
ret_images = []
for i in image:
i = torch.unsqueeze(i,0)
__image = tensor2pil(i)
ret_image = __image.convert('RGB')
if brightness != 1:
brightness_image = ImageEnhance.Brightness(ret_image)
ret_image = brightness_image.enhance(factor=brightness)
if contrast != 1:
contrast_image = ImageEnhance.Contrast(ret_image)
ret_image = contrast_image.enhance(factor=contrast)
if saturation != 1:
color_image = ImageEnhance.Color(ret_image)
ret_image = color_image.enhance(factor=saturation)
if __image.mode == 'RGBA':
ret_image = RGB2RGBA(ret_image, __image.split()[-1])
ret_images.append(pil2tensor(ret_image))
log(f"{NODE_NAME} Processed {len(ret_images)} image(s).", message_type='finish')
return (torch.cat(ret_images, dim=0),)
NODE_CLASS_MAPPINGS = {
"LayerColor: Brightness & Contrast": ColorCorrectBrightnessAndContrast
}
NODE_DISPLAY_NAME_MAPPINGS = {
"LayerColor: Brightness & Contrast": "LayerColor: Brightness & Contrast"
from .imagefunc import *
NODE_NAME = 'Brightness & Contrast'
class ColorCorrectBrightnessAndContrast:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(self):
return {
"required": {
"image": ("IMAGE", ), #
"brightness": ("FLOAT", {"default": 1, "min": 0.0, "max": 3, "step": 0.01}),
"contrast": ("FLOAT", {"default": 1, "min": 0.0, "max": 3, "step": 0.01}),
"saturation": ("FLOAT", {"default": 1, "min": 0.0, "max": 3, "step": 0.01}),
},
"optional": {
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("image",)
FUNCTION = 'color_correct_brightness_and_contrast'
CATEGORY = '😺dzNodes/LayerColor'
def color_correct_brightness_and_contrast(self, image, brightness, contrast, saturation):
ret_images = []
for i in image:
i = torch.unsqueeze(i,0)
__image = tensor2pil(i)
ret_image = __image.convert('RGB')
if brightness != 1:
brightness_image = ImageEnhance.Brightness(ret_image)
ret_image = brightness_image.enhance(factor=brightness)
if contrast != 1:
contrast_image = ImageEnhance.Contrast(ret_image)
ret_image = contrast_image.enhance(factor=contrast)
if saturation != 1:
color_image = ImageEnhance.Color(ret_image)
ret_image = color_image.enhance(factor=saturation)
if __image.mode == 'RGBA':
ret_image = RGB2RGBA(ret_image, __image.split()[-1])
ret_images.append(pil2tensor(ret_image))
log(f"{NODE_NAME} Processed {len(ret_images)} image(s).", message_type='finish')
return (torch.cat(ret_images, dim=0),)
NODE_CLASS_MAPPINGS = {
"LayerColor: Brightness & Contrast": ColorCorrectBrightnessAndContrast
}
NODE_DISPLAY_NAME_MAPPINGS = {
"LayerColor: Brightness & Contrast": "LayerColor: Brightness & Contrast"
}