From a757ab2752d7e841bb42fdca5072066db9d5a28e Mon Sep 17 00:00:00 2001 From: Raykosan <71210053+Raykosan@users.noreply.github.com> Date: Tue, 17 Mar 2026 02:59:06 +0300 Subject: [PATCH] Small changes --- RS_Saturation_switch.py => RS_Saturation.py | 114 ++++++++++---------- 1 file changed, 57 insertions(+), 57 deletions(-) rename RS_Saturation_switch.py => RS_Saturation.py (84%) diff --git a/RS_Saturation_switch.py b/RS_Saturation.py similarity index 84% rename from RS_Saturation_switch.py rename to RS_Saturation.py index a87a969..b928c90 100644 --- a/RS_Saturation_switch.py +++ b/RS_Saturation.py @@ -1,57 +1,57 @@ -import torch -from comfy.model_patcher import ModelPatcher - -print("\033[93m🦊\033[0m \033[93mRaykoStudio - RS SaturationNode \033[92mLOADED\033[0m") - -class RS_SaturationSwitch: - @classmethod - def INPUT_TYPES(cls): - return { - "required": { - "image": ("IMAGE",), - "intensity": ("FLOAT", { - "default": 1.0, - "min": 0.0, - "max": 3.0, - "step": 0.05, - "display_name": "Intensity", - "description": "0.0=Grayscale, 1.0=Original, 1.5=Subtle Boost" - }), - }, - } - - RETURN_TYPES = ("IMAGE",) - FUNCTION = "apply_saturation" - CATEGORY = "🦊 RaykoStudio/Image" - DESCRIPTION = "Artifact-free saturation control with proper tensor handling" - - def apply_saturation(self, image, intensity): - if intensity == 1.0: - return (image,) - - img = image.clone().float() - - r, g, b = img[..., 0], img[..., 1], img[..., 2] - l = 0.299 * r + 0.587 * g + 0.114 * b - l = l.unsqueeze(-1) - - if intensity < 1.0: - result = l + intensity * (img - l) - else: - boost = 1.0 + (intensity - 1.0) * 0.7 - delta = img - l - result = l + boost * delta - - result = torch.where( - (result < 0) | (result > 1), - l + 0.9 * delta, - result - ) - - if result.dim() == 3: - result = result.unsqueeze(0) - - return (result.clamp(0, 1).to(image.dtype),) - -NODE_CLASS_MAPPINGS = {"RS_SaturationSwitch": RS_SaturationSwitch} -NODE_DISPLAY_NAME_MAPPINGS = {"RS_SaturationSwitch": "🦊 RS Safe Saturation"} \ No newline at end of file +import torch +from comfy.model_patcher import ModelPatcher + +print("\033[93m🦊\033[0m \033[93mRaykoStudio - RS Saturation \033[92mLOADED\033[0m") + +class RS_SaturationSwitch: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image": ("IMAGE",), + "intensity": ("FLOAT", { + "default": 1.0, + "min": 0.0, + "max": 3.0, + "step": 0.05, + "display_name": "Intensity", + "description": "0.0=Grayscale, 1.0=Original, 1.5=Subtle Boost" + }), + }, + } + + RETURN_TYPES = ("IMAGE",) + FUNCTION = "apply_saturation" + CATEGORY = "🦊 RaykoStudio/Image" + DESCRIPTION = "Artifact-free saturation control with proper tensor handling" + + def apply_saturation(self, image, intensity): + if intensity == 1.0: + return (image,) + + img = image.clone().float() + + r, g, b = img[..., 0], img[..., 1], img[..., 2] + l = 0.299 * r + 0.587 * g + 0.114 * b + l = l.unsqueeze(-1) + + if intensity < 1.0: + result = l + intensity * (img - l) + else: + boost = 1.0 + (intensity - 1.0) * 0.7 + delta = img - l + result = l + boost * delta + + result = torch.where( + (result < 0) | (result > 1), + l + 0.9 * delta, + result + ) + + if result.dim() == 3: + result = result.unsqueeze(0) + + return (result.clamp(0, 1).to(image.dtype),) + +NODE_CLASS_MAPPINGS = {"RS_Saturation": RS_SaturationSwitch} +NODE_DISPLAY_NAME_MAPPINGS = {"RS_Saturation": "🦊 RS Saturation"} \ No newline at end of file