meccatronis commited on
Commit
b3a6ed2
·
verified ·
1 Parent(s): 9a7b98f

Upload node_wrappers/recolor.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. node_wrappers/recolor.py +46 -0
node_wrappers/recolor.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ..utils import common_annotator_call, define_preprocessor_inputs, INPUT
2
+
3
+ class ImageLuminanceDetector:
4
+ @classmethod
5
+ def INPUT_TYPES(s):
6
+ #https://github.com/Mikubill/sd-webui-controlnet/blob/416c345072c9c2066101e225964e3986abe6945e/scripts/processor.py#L1229
7
+ return define_preprocessor_inputs(
8
+ gamma_correction=INPUT.FLOAT(default=1.0, min=0.1, max=2.0),
9
+ resolution=INPUT.RESOLUTION()
10
+ )
11
+
12
+ RETURN_TYPES = ("IMAGE",)
13
+ FUNCTION = "execute"
14
+
15
+ CATEGORY = "ControlNet Preprocessors/Recolor"
16
+
17
+ def execute(self, image, gamma_correction=1.0, resolution=512, **kwargs):
18
+ from custom_controlnet_aux.recolor import Recolorizer
19
+ return (common_annotator_call(Recolorizer(), image, mode="luminance", gamma_correction=gamma_correction , resolution=resolution), )
20
+
21
+ class ImageIntensityDetector:
22
+ @classmethod
23
+ def INPUT_TYPES(s):
24
+ #https://github.com/Mikubill/sd-webui-controlnet/blob/416c345072c9c2066101e225964e3986abe6945e/scripts/processor.py#L1229
25
+ return define_preprocessor_inputs(
26
+ gamma_correction=INPUT.FLOAT(default=1.0, min=0.1, max=2.0),
27
+ resolution=INPUT.RESOLUTION()
28
+ )
29
+
30
+ RETURN_TYPES = ("IMAGE",)
31
+ FUNCTION = "execute"
32
+
33
+ CATEGORY = "ControlNet Preprocessors/Recolor"
34
+
35
+ def execute(self, image, gamma_correction=1.0, resolution=512, **kwargs):
36
+ from custom_controlnet_aux.recolor import Recolorizer
37
+ return (common_annotator_call(Recolorizer(), image, mode="intensity", gamma_correction=gamma_correction , resolution=resolution), )
38
+
39
+ NODE_CLASS_MAPPINGS = {
40
+ "ImageLuminanceDetector": ImageLuminanceDetector,
41
+ "ImageIntensityDetector": ImageIntensityDetector
42
+ }
43
+ NODE_DISPLAY_NAME_MAPPINGS = {
44
+ "ImageLuminanceDetector": "Image Luminance",
45
+ "ImageIntensityDetector": "Image Intensity"
46
+ }