File size: 1,856 Bytes
74f4a06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from ..utils import common_annotator_call, define_preprocessor_inputs, INPUT

class ImageLuminanceDetector:
    @classmethod
    def INPUT_TYPES(s):
        #https://github.com/Mikubill/sd-webui-controlnet/blob/416c345072c9c2066101e225964e3986abe6945e/scripts/processor.py#L1229
        return define_preprocessor_inputs(
            gamma_correction=INPUT.FLOAT(default=1.0, min=0.1, max=2.0),
            resolution=INPUT.RESOLUTION()
        )

    RETURN_TYPES = ("IMAGE",)
    FUNCTION = "execute"

    CATEGORY = "ControlNet Preprocessors/Recolor"

    def execute(self, image, gamma_correction=1.0, resolution=512, **kwargs):
        from custom_controlnet_aux.recolor import Recolorizer
        return (common_annotator_call(Recolorizer(), image, mode="luminance", gamma_correction=gamma_correction , resolution=resolution), )

class ImageIntensityDetector:
    @classmethod
    def INPUT_TYPES(s):
        #https://github.com/Mikubill/sd-webui-controlnet/blob/416c345072c9c2066101e225964e3986abe6945e/scripts/processor.py#L1229
        return define_preprocessor_inputs(
            gamma_correction=INPUT.FLOAT(default=1.0, min=0.1, max=2.0),
            resolution=INPUT.RESOLUTION()
        )

    RETURN_TYPES = ("IMAGE",)
    FUNCTION = "execute"

    CATEGORY = "ControlNet Preprocessors/Recolor"

    def execute(self, image, gamma_correction=1.0, resolution=512, **kwargs):
        from custom_controlnet_aux.recolor import Recolorizer
        return (common_annotator_call(Recolorizer(), image, mode="intensity", gamma_correction=gamma_correction , resolution=resolution), )

NODE_CLASS_MAPPINGS = {
    "ImageLuminanceDetector": ImageLuminanceDetector,
    "ImageIntensityDetector": ImageIntensityDetector
}
NODE_DISPLAY_NAME_MAPPINGS = {
    "ImageLuminanceDetector": "Image Luminance",
    "ImageIntensityDetector": "Image Intensity"
}