From c2be3f52d8e6fb438eb25262e9b8c1a5c8c0ed98 Mon Sep 17 00:00:00 2001 From: Clybius <55800048+Clybius@users.noreply.github.com> Date: Fri, 15 Sep 2023 20:05:55 -0500 Subject: [PATCH 1/2] Update README.md for Contrast update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 242864d..dcd94eb 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,5 @@ This can lead to more perceptual detail, especially at higher strengths. * Rescale: Scales the CFG by comparing the standard deviation to the existing latent to dynamically lower the CFG. * Extra Noise: Adds extra noise in the middle of the diffusion process, akin to how sharpness sharpens the noise. + +* Contrast: Adjusts the contrast of the conditioning, can lead to more pop-style results. Essentially functions as a secondary CFG slider for stylization, without changing subject pose and location much, if at all. From 328f9590bb0384be3edcd01114aa7161a33e5b81 Mon Sep 17 00:00:00 2001 From: Clybius <55800048+Clybius@users.noreply.github.com> Date: Sat, 16 Sep 2023 15:18:37 -0500 Subject: [PATCH 2/2] Add explanations to functions in README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index dcd94eb..6864aaa 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,27 @@ This can lead to more perceptual detail, especially at higher strengths. * Extra Noise: Adds extra noise in the middle of the diffusion process, akin to how sharpness sharpens the noise. * Contrast: Adjusts the contrast of the conditioning, can lead to more pop-style results. Essentially functions as a secondary CFG slider for stylization, without changing subject pose and location much, if at all. + +### Tonemapping Methods Explanation: +* Reinhard:
Uses the reinhard method of tonemapping (from comfyanonymous' ComfyUI Experiments) to clamp the CFG if the difference is too strong. + + Lower `tonemap_multiplier` clamps more noise, and a lower `tonemap_percentile` will increase the calculated standard deviation from the original noise. Play with it!
+* Arctan:Clamps the values dynamically using a simple arctan curve. [Link to interactive Desmos visualization](https://www.desmos.com/calculator/e4nrcdpqbl). + + Recommended values for testing: tonemap_multiplier of 5, tonemap_percentile of 90.
+* Quantile:Clamps the values using torch.quantile for obtaining the highest magnitudes, and clamping based on the result. + + + `Closer to 100 percentile == stronger clamping`. Recommended values for testing: tonemap_multiplier of 1, tonemap_percentile of 99.
+ +### Contrast Explanation: +Scales the pixel values by the standard deviation, achieving a more contrasty look. In practice, this can effectively act as a secondary CFG slider for stylization. It doesn't modify subject poses much, if at all, which can be great for those looking to get more oomf out of their low-cfg setups.
+ +#### Current Pipeline: +>##### Add extra noise to conditioning -> Sharpen conditioning -> Tonemap conditioning -> Modify contrast of conditioning -> Rescale CFG + +#### Why use this over `x` node? +Since the `set_model_sampler_cfg_function` hijack in ComfyUI can only utilize a single function, we bundle many latent modification methods into one large function for processing. This is simpler than taking an existing hijack and modifying it, which may be possible, but my (Clybius') lack of Python/PyTorch knowledge leads to this being the optimal method for simplicity. If you know how to do this, feel free to reach out through any means! + +#### Can you implement `x` function? +Depends. Is there existing code for such a function, with an open license for possible use in this repository? I could likely attempt adding it! Feel free to start an issue or to reach out for ideas you'd want implemented.