diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f5a0e9..c933a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -### v2.0.0 - 2024 Mar.01 +### v2.0.0 - 2024 Mar.04 +- Support **SDXL** + +### v2.0.gamma - 2024 Mar.01 - Major **Rewrite** & **Optimization** ### v2.0.beta - 2024 Feb.29 diff --git a/LICENSE b/LICENSE index b0340f4..91b74be 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Haoming +Copyright (c) 2024 Haoming Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2b535d4..d39d157 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ allowing you to adjust the brightness, contrast, and color of the generations. > Also compatible with [Forge](https://github.com/lllyasviel/stable-diffusion-webui-forge)! -**Important:** The color currently only works for **SD 1.5** Checkpoints +> Now supports SDXL! > [Sample Images](#sample-images) @@ -12,7 +12,7 @@ allowing you to adjust the brightness, contrast, and color of the generations. After installing this Extension, you will see a new section in both **txt2img** and **img2img** tabs. Refer to the parameters and sample images below and play around with the values. -**Note:** Since this modifies the underlying latent noise, the composition may change drastically. Using the **Ones** scaling seems to reduce the variations. +**Note:** Since this modifies the underlying latent noise, the composition may change drastically. #### Parameters - **Enable:** Turn on/off this Extension @@ -85,15 +85,16 @@ Refer to the parameters and sample images below and play around with the values. - **Abs:** Calculate using the absolute values of the chosen Tensors instead - `x += abs(F) * y` -


+
+
-Alt. Disabled
-
+
-Alt. Enabled
-
-
Notice the blurriness and the noises on Flat scaling
-Base
-Extension Disabled
-
+Disabled
+
-Dark
-Brightness: -3; Contrast: 1.5
-
+Brightness: 2.5 ; Contrast: -0.5 ; Saturation: 1.5
+R: 2.5; G: 2.5; B: -4
+
-Bright
-Brightness: 2.5; Contrast: 0.5; Alt: Enabled
-
+Brightness: -2.5 ; Contrast: 0.5 ; Saturation: 1.5
+R: -1; G: -1; B: 2.5
+
-Chill
-Brightness: -2.5; Contrast: 1.25
-R: -1.5; B: 2.5
-
-
-Mexican Movie
-Brightness: 3; Saturation: 1.5
-R: 2; G: 1; B: -2
-
-
Notice the significant differences even when using the same seed
- ## Roadmap - [X] Extension Released - [X] Add Support for **X/Y/Z Plot** @@ -169,15 +143,18 @@ Therefore, I added a scaling option to modify the offset amount throughout the p - You can enable this in the **Infotext** section of the **Settings** tab - [X] Add Infotext Support *(by. [catboxanon](https://github.com/catboxanon))* - [X] ADD **HDR** Script +- [X] Add SDXL Support - [ ] Add Gradient features -- [ ] Add SDXL Support -X/Y/Z Plot Support
(Outdated Contrast Value)

+X/Y/Z Plot Support
+
+
X/Y/Z Plot w/ Randomize

The value is used as the random seed
You can refer to the console to see the randomized values
+Randomize
+
+The value is used as the random seed
You can refer to the console to see the randomized values
BETA
diff --git a/samples/00.jpg b/samples/00.jpg index 9ccaa26..8eee988 100644 Binary files a/samples/00.jpg and b/samples/00.jpg differ diff --git a/samples/01.jpg b/samples/01.jpg index ce2e102..48eb847 100644 Binary files a/samples/01.jpg and b/samples/01.jpg differ diff --git a/samples/02.jpg b/samples/02.jpg index 246f203..cadedfa 100644 Binary files a/samples/02.jpg and b/samples/02.jpg differ diff --git a/samples/03.jpg b/samples/03.jpg deleted file mode 100644 index 9bbe8d8..0000000 Binary files a/samples/03.jpg and /dev/null differ diff --git a/samples/04.jpg b/samples/04.jpg deleted file mode 100644 index 0e1d214..0000000 Binary files a/samples/04.jpg and /dev/null differ diff --git a/samples/Bright.jpg b/samples/Bright.jpg deleted file mode 100644 index 997bbc1..0000000 Binary files a/samples/Bright.jpg and /dev/null differ diff --git a/samples/Dark.jpg b/samples/Dark.jpg deleted file mode 100644 index d1f8459..0000000 Binary files a/samples/Dark.jpg and /dev/null differ diff --git a/samples/Method.jpg b/samples/Method.jpg new file mode 100644 index 0000000..b3a8b6a Binary files /dev/null and b/samples/Method.jpg differ diff --git a/samples/Random.jpg b/samples/Random.jpg index cf8c273..0123cfa 100644 Binary files a/samples/Random.jpg and b/samples/Random.jpg differ diff --git a/samples/Scaling.jpg b/samples/Scaling.jpg index 7f1bbfe..4771a38 100644 Binary files a/samples/Scaling.jpg and b/samples/Scaling.jpg differ diff --git a/samples/Scaling_alt.jpg b/samples/Scaling_alt.jpg deleted file mode 100644 index 18c06bf..0000000 Binary files a/samples/Scaling_alt.jpg and /dev/null differ diff --git a/samples/XYZ.jpg b/samples/XYZ.jpg index 36822f5..e68b904 100644 Binary files a/samples/XYZ.jpg and b/samples/XYZ.jpg differ diff --git a/scripts/cc_callback.py b/scripts/cc_callback.py index 16fca98..438d44c 100644 --- a/scripts/cc_callback.py +++ b/scripts/cc_callback.py @@ -62,6 +62,14 @@ class NoiseMethods: return noise / noise.std() +def RGB_2_CbCr(r:float, g:float, b:float) -> float: + """Convert RGB channels into YCbCr for SDXL""" + cb = -0.15 * r - 0.29 * g + 0.44 * b + cr = 0.44 * r - 0.37 * g - 0.07 * b + + return cb, cr + + original_callback = KDiffusionSampler.callback_state @torch.no_grad() @@ -72,6 +80,8 @@ def cc_callback(self, d): if getattr(self.p, "is_hr_pass", False) and not self.vec_cc["doHR"]: return original_callback(self, d) + is_xl: bool = self.p.sd_model.is_sdxl + mode = str(self.vec_cc["mode"]) method = str(self.vec_cc["method"]) source = d[mode] @@ -108,23 +118,42 @@ def cc_callback(self, d): self.vec_cc["b"], ) - for i in range(batchSize): - # Brightness - source[i][0] += target[i][0] * bri - # Contrast - source[i][0] += NoiseMethods.get_delta(source[i][0]) * con + if not is_xl: + for i in range(batchSize): + # Brightness + source[i][0] += target[i][0] * bri + # Contrast + source[i][0] += NoiseMethods.get_delta(source[i][0]) * con - # R - source[i][2] -= target[i][2] * r - # G - source[i][1] += target[i][1] * g - # B - source[i][3] -= target[i][3] * b + # R + source[i][2] -= target[i][2] * r + # G + source[i][1] += target[i][1] * g + # B + source[i][3] -= target[i][3] * b - # Saturation - source[i][2] *= sat - source[i][1] *= sat - source[i][3] *= sat + # Saturation + source[i][2] *= sat + source[i][1] *= sat + source[i][3] *= sat + + else: + # But why... + cb, cr = RGB_2_CbCr(r, b, g) + + for i in range(batchSize): + # Brightness + source[i][0] += target[i][0] * bri + # Contrast + source[i][0] += NoiseMethods.get_delta(source[i][0]) * con + + #CbCr + source[i][1] -= target[i][1] * cr + source[i][2] += target[i][2] * cb + + # Saturation + source[i][1] *= sat + source[i][2] *= sat return original_callback(self, d)