10 Commits
Author SHA1 Message Date
Extraltodeus 967b181646 Update nodes.py 2025-05-24 09:36:22 +02:00
Extraltodeus 75644eb9c5 Merge pull request #5 from Extraltodeus/revert-4-update-publish-yaml
Revert "Update Github Action for Publishing to Comfy Registry"
2025-04-29 19:04:07 +02:00
Extraltodeus 870bfda221 Revert "Update Github Action for Publishing to Comfy Registry" 2025-04-29 19:03:54 +02:00
Extraltodeus 9b96958673 Merge pull request #4 from ComfyNodePRs/update-publish-yaml
Update Github Action for Publishing to Comfy Registry
2025-04-29 19:02:03 +02:00
Extraltodeus b43585debc Update README.md 2025-04-29 19:00:55 +02:00
Extraltodeus efc4702b3a Update README.md 2025-04-29 18:59:59 +02:00
snomiao 9378d9d222 chore(publish): update workflow for node publishing with permissions and condition adjustments 2025-01-20 23:06:47 +00:00
Extraltodeus 195e434380 Update README.md 2024-09-23 04:51:36 +02:00
Extraltodeus 5e0aaf5c7c Update README.md 2024-09-23 04:50:26 +02:00
Extraltodeus b9294aea12 Update README.md 2024-09-23 04:49:59 +02:00
2 changed files with 69 additions and 55 deletions
+68 -54
View File
@@ -15,9 +15,76 @@ All are to be used like any model patching node, right after the model loader.
# Nodes:
## Other nodes
There are now too many nodes for me to just add a screenshot and a bunch of details but it would be a shame not to describe them:
- Perturbed attention guidance: adaptation of PAG as a pre-CFG node.
- Variable CFG: Make you scale vary along the generation
- channel multipliers
- subtract prediction mean: gives more balanced colors
- "flip flop": swap the positive with the negative. Since the order matter, you may chain it with other nodes and go back to the correct order after. For experimental purposes.
- Shape attention (for SDXL) can turn off the input layer 8.
- Support empty uncond: Combined with "menu>advanced>conditioning>set timestep range" at ~65% you can now get a speed boost on any workflow.
- Set timestep range from sigmas: same as the default node except that you're using sigmas instead of step percentage
- [The testing branch](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/tree/testing_wip) has a few more and is the current state of these nodes for me.
## Pre CFG automatic scale
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/0437bf5e-1864-41ce-b929-654612b648a6)
### mode:
- Automatic CFG: applies the same predictable scaling as my other nodes based on this logic
- Strict scaling: applies a scaling which will always give the exact desired value. This tends to create artifacts and random blurs if carried through the end.
### Support empty uncond:
If you use the already available node named ConditioningSetTimestepRange you can stop generating a negative prediction earlier by letting your negative conditioning go through it while setting it like this:
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/4bb39087-d02a-4dd9-821d-dc1f43870eb0)
This speeds up your generation speed by two for the steps where there is no negative.
The only issue if you do this is that the CFG function will weight your positive prediction times your CFG scale against nothing and you will get a black image.
"support_empty_uncond" therefore divides your positive prediction by your CFG scale and avoids this issue.
Doing this combination is similar to the "boost" feature of my original automatic CFG node. It can also let you avoid artifacts if you want to use the strict scaling.
If you want to use this option in a chained setup using this node multiple times I recommand to use it only once and on the last.
## Pre CFG perp-neg
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/606b2ff3-fb81-4964-8e6d-cee97011a623)
Applies the already known [perp-neg logic](https://perp-neg.github.io/).
Code taken and adapted from ComfyAnon implementation.
The context length (added after the screenshot of the node) can be set to a higher value if you are using a tensor rt engine requiring a higher context length.
For more details you can check [my node related to this "Conditioning crop or fill"](https://github.com/Extraltodeus/Uncond-Zero-for-ComfyUI?tab=readme-ov-file#conditioning-crop-or-fill) where I explain a bit more about this.
## Pre CFG sharpening (experimental)
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/ffca8fae-34b0-44fa-bcd5-dc2ed2c625ca)
Subtract from the current step something from the previous step. This tends to make the images sharper and less saturated.
A negative value can be set.
## Pre CFG exponentiation (experimental)
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/34367216-eccf-411e-8fab-c63ff0f24331)
A value lower than one will simplify the end result and enhance the saturation / contrasts.
A value higher than one will do the opposite and if pushed too far will most likely make a mess.
## Gradient scaling:
Named like this because I initially wanted to test what would happen if I used, instead of a single CFG scale, a tensor shaped like the latent space with a gradual variation. So, not the kind of gradient used for backpropagation. Then why not try to use masks instead? And what if I could make it so each value will participate so the image would match as close as possible to an input image?
Named like this because I initially wanted to test what would happen if I used, instead of a single CFG scale, a tensor shaped like the latent space with a gradual variation. And then why not try to use masks instead? And what if I could make it so each value will match as closely as possible another input image?
The result is an arithmetic scaling method which does not noticeably slow down the sampling while also scaling the intensity of the values like an "automatic cfg".
@@ -79,56 +146,3 @@ Note:
- Given that this is a non-ml solution, unlike controlnet, it can not tell the difference in between a banana and a person. It simply tries to make the values match the input image. A giraffe is just an apple with different values at a different place.
- It is possible to chain multiple times this node for as long as the sum of all the strength sliders is equal or below one.
- I added two image generators. One simply using RGB sliders and a gradient generator which can also make circular patterns while outputting a mask, to make vignetting easy. You will find them in the "image" category.
## Pre CFG automatic scale
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/0437bf5e-1864-41ce-b929-654612b648a6)
### mode:
- Automatic CFG: applies the same predictable scaling as my other nodes based on this logic
- Strict scaling: applies a scaling which will always give the exact desired value. This tends to create artifacts and random blurs if carried through the end.
### Support empty uncond:
If you use the already available node named ConditioningSetTimestepRange you can stop generating a negative prediction earlier by letting your negative conditioning go through it while setting it like this:
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/4bb39087-d02a-4dd9-821d-dc1f43870eb0)
This speeds up your generation speed by two for the steps where there is no negative.
The only issue if you do this is that the CFG function will weight your positive prediction times your CFG scale against nothing and you will get a black image.
"support_empty_uncond" therefore divides your positive prediction by your CFG scale and avoids this issue.
Doing this combination is similar to the "boost" feature of my original automatic CFG node. It can also let you avoid artifacts if you want to use the strict scaling.
If you want to use this option in a chained setup using this node multiple times I recommand to use it only once and on the last.
## Pre CFG perp-neg
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/606b2ff3-fb81-4964-8e6d-cee97011a623)
Applies the already known [perp-neg logic](https://perp-neg.github.io/).
Code taken and adapted from ComfyAnon implementation.
The context length (added after the screenshot of the node) can be set to a higher value if you are using a tensor rt engine requiring a higher context length.
For more details you can check [my node related to this "Conditioning crop or fill"](https://github.com/Extraltodeus/Uncond-Zero-for-ComfyUI?tab=readme-ov-file#conditioning-crop-or-fill) where I explain a bit more about this.
## Pre CFG sharpening (experimental)
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/ffca8fae-34b0-44fa-bcd5-dc2ed2c625ca)
Subtract from the current step something from the previous step. This tends to make the images sharper and less saturated.
A negative value can be set.
## Pre CFG exponentiation (experimental)
![image](https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI/assets/15731540/34367216-eccf-411e-8fab-c63ff0f24331)
A value lower than one will simplify the end result and enhance the saturation / contrasts.
A value higher than one will do the opposite and if pushed too far will most likely make a mess.
+1 -1
View File
@@ -323,7 +323,7 @@ class automatic_pre_cfg:
def patch(self, model, scaling_method, min_max_method="difference", reference_CFG=8, scale_multiplier=0.8, top_k=0.25, channels_selection=None):
parameters_string = f"scaling_method: {scaling_method}\nmin_max_method: {min_max_method}"
if channels_selection is not None:
for x in range(channels_selection):
for x in range(len(channels_selection)):
parameters_string += f"\nchannel {x+1}: {channels_selection[x]}"
scaling_methods_names = [k for k in apply_scaling_methods]
@torch.no_grad()