Home Creators Posts Import Register Favorites Logout

Downloads

Content

Video - https://youtu.be/zadmCLoJbMI

Overview

Switches. Simple? Any? Lenient?

If you're facing a choice then switches are great! You can make all sorts of decisions before you hit "run". Do you want to use this model or that one? Should this happen if you have a mask or not? How about if your prompt has the word "photographic" in it?

This week I take a look at the new Lenient Switch custom nodes where they have both a simple switch and a lenient one with lots of logic ready-to-go.

https://github.com/id-fa/ComfyUI-Lenient-Switch

One use for switches is to pick which model you'd like to use as a refiner for Qwen or HiDream (or whatever) - and that is the path I've gone down for the attached workflows. Great if you want to try various things without having lots of tabs open, each with a different model and workflow in.

Whilst the Lenient Switch has uses far beyond just model switching, I figured this would be a great place to start, as it shows both switches in action and how labels can be used to provide some automation later on down the line. This means you don't have to keep switching many switches as logic later on can do things for you.

Whilst I've focused on image refiners this week, you could use the same logic to generate your initial image, or a whole range of other things. For example, you could keep the prompt the same and just see which of your 4 favourite models do the best, or maybe you have something more complex you've always wanted to do but never had a node to handle it!

Workflow Information

As both Qwen Image Edit and HiDream are stand-out models at being able to use source images for the initial generation, I figured these would be prime examples for adding refiner options to.

Being recent models, I chose the turbo versions of ERNIE, Lens and Z-Image as the refiners, though its easy enough to replace any option with your own favourite model.

Qwen Image Workflow

My Qwen Image Edit is the first workflow with lenient switch example - as well as a few other updated!

Model Download Links

Links are included in-workflow for the various default models used:

Updates

As well as the refiners, I've also updated the automasking to use the new SAM3 model and added some bookmarks for speedy section navigation:

Custom Nodes

Compared to my previous QIE workflow release, only 1 extra set of custom nodes is required:

I've also removed the REMBG requirement as SAM3 handles that now.

SAM 3

Also, if you are loading an image, you can easily switch between manual and automated masking:

Either way, masking won't be used unless you select the Masked Image 1 option from the control panel. By default, it just has the Empty Latent option selected so a mask won't be used.

Image Upscaling / Refining

The Image Refiner allows you to select one of three other models, and this is where the first of the ComfyUI Lenient Switches comes in - the Simple Selector:

Rather than using an AnySwitch combined with a Group Muter / Bypass, you can now use a single node which has the switch built-in.

This way, the loaders for ERNIE, Lens & Z-Image are all controlled via the Simple Selector in the Upscale Choice group. To select a model to use as the refiner, just pick an option from the Model Select combo box:

A = ERNIE

B = Lens

C = Z-Image

D = Qwen

This matches the manually entered names for each source label, as shown in the screenshot above.

The CLIP and VAE switches are all linked in, so you only need to make the selection once via the combo box, and all the other options will be set too.

The Detail Upscale 1 group will then use whichever model group you have selected:

Even though there are lots of models possible in a single workflow, Comfy's built-in Dynamic Loading will make sure you don't run out of memory, so long as you haven't opted to disable it!

This is also where we see the other switch in action - the Lenient Switch:

Whilst it doesn't apply to the other options (ERNIE, Lens & Z-Image), for Qwen Image Edit you might have chosen to encode one or more images at the start...

... which automatically get chosen via the Any Switch:

Because the Replace Text node returns an empty string if the label is Qwen Image, and we have treat_empty_string_as_false enabled, this means pass_if_a fails when you have the Qwen Image model loaded.

As it passes a, the next option is b - which is the Qwen conditioning you selected for the initial image generation! As such, the refiner will now use any images you had selected in this second pass as well.

This is just one way to use the logic built-in to the Lenient Switch, and many more complicated scenarios could also be handled. See their GitHub page for a couple of ideas and more documentation!

The Detail Upscale 2 group uses Qwen again, as some models aren't as good at text as Qwen, plus you may wish to re-apply any of your input images:

This second upscale option has both good and bad effects. Depending on your denoise value, you may be able to repair text or faces from your input images... but you'll also get that Qwen Image smoothness re-applied as well, losing some of the detail from upscale 1.

You can, of course, chose not to do the second upscale. It all depends on what you're trying to achieve!

Re-Prompting

Finally, as you may be using editing commands in your initial prompt, the refiner prompt may benefit from being different. This is where the AI Re-Prompt comes in handy:

This way, rather than sending an editing command to Z-Image, it will see a more descriptive prompt of the image you generated to start with. In practice, this isn't often needed with low denoise values - but you may not always be using low denoise values! If you've doing more creative refining, then at updated prompt works wonders.

HiDream Image Workflow

My HiDream workflow also uses the same refiner set as in the Qwen Image Edit workflow, and so now also needs the Lenient Switch custom node pack installed.

The refiner group work in much the same way as in QIE, but this time you have multiple image options for your initial generation, and so in the refiner you'll need to pick which of the initial generations you want to use:

Yes - this could be another job for the one of the Lenient Switches! Need more time to play around and see if it would work well...

You can also choose which conditioning to apply in your refiner:

For example, if you chose to use Reference Images, then you may like to use the +VE_REF conditioning when using the HiDream model, or leave it with the default prompt.

Which Refiner Is Best?

That all depends on the task at hand - and you'll be able to see for yourself when you try! They all have their own little quirks, pros and cons.

ERNIE, for example, is very good at text whereas Lens or Z-Image may mess things up. It also has a great range of styles, and follows the prompt really well. However, it also tends towards an Eastern look for human subjects so you may need to prompt accordingly, and it can get "over-crisp".

Lens can add quite a bit of detail, but will also tend towards photorealism and lighten the image up a lot. Higher denoise values with Lens can be interesting.

Z-Image doesn't have the same style range or text capabilities of ERNIE, but can work well on photo-real human subjects. It also changes the image quite a lot if you have a denoise greater than 0.55. One easy swap here would be the Z-Anime model, which could be a good choice if you're making that style of image.

And all of these model differences is exactly why a quick way to switch between models is really handy. Use whatever is best for your own image creations!

Enjoy! :)

Files

Comments

No comments found for this post.