Sign In

Extension Series - Part 1: Dynamic Thresholds

8
Extension Series - Part 1: Dynamic Thresholds

Note to the Reader: All the images provided in this article are bare generations. This means no upscaling, no ADetailer, etc. It's just you, me, the model, and Dynamic Thresholds.

Hello and welcome, or welcome back, to my little corner of the AI Generative Jungle.

We are starting a new series with this one! Exciting stuff, I know!

Today we are going to talk about an extension that I don't see talked about a lot here on CivitAI. That extension is:

Dynamic Thresholds (CFG Scaling Fix) or DynThres. A powerful, and seemingly, under used tool in our toolbox that brings a lot to the table.

This article will delve into:

  • What the extension does

  • Complex Use Cases

  • Applications to Different 1.x Models

  • Application to Different Model Types (XL, XL-T, XL-L, Pony)

(Note: I'm not going to go into how to initially configure DynThres in this article. If you'd like to download it and try it for yourself you can read the following article where I give you the link and instructions on how to initially configure it.) Workflow Series Part 1

I will provide examples where needed so you can see the extension in action.

Section 1 - What does DynThres Do:

If you have ever messed around with the CFG scale on your own, then you'll be familiar with the artifact and "burning" issues that occur at high scale (Usually starting around 12-15 in most cases).

DynThres, simply put, resolves these issues by allowing you to raise the CFG scale past that threshold and beyond. Adding a level of accuracy and detail to your generations that would be difficult to obtain otherwise.

There are, of course, other options available to increase levels of detail in generations, but they can often be "rigid" as far as where and how that detail is added. With DynThres you get all that detail and still maintain complete control of your generation.

But don't take my word for it! Let's take a look at a comparison shall we?

Below are two generations (same prompt; same seed). The first is the vanilla CFG scale at work and the second is with the extension applied.

Prompt:

A woman sitting on a log in a field

The seed:

3674516383

Normal CFG Scale: 8

DynThres CFG Scale: 20 mimic 8

And that right there is what DynThres does. While neither image is perfect, which one would you choose to move forward with? I'd personally choose DynThres all day, everyday.

So what is happening here? Well, what DynThres has done in the 2nd image is allowed me to crank up the CFG Scale to 20. It does this by using a "mimic" scale. In this case that mimic scale is 8, the same as our vanilla generation.

Now I'm not gonna sit here and tell you that I know exactly how DynThres does this, because I don't. I just know that it works and am slowly starting to understand it's limits. However, if you follow what I'm about to tell you, you'll be generating hyper detailed images in no time at all.

Section 2 - Complex Use Cases:

In the example above I showed you an uber basic prompt and generation. But what about a complex prompt. What advantages does DynThres bring to that table? Well let's take a look shall we?

Let's write ourselves a more complex prompt. Something that incorporates a moderate amount of instructions and details for SD to deal with.

Prompt:

(((Epic-Upscaled-Resolution, Epic-Photogasm, Ultra-HD-Details, Ultra-HD-Detailed, Ultra-HD-Realistic, Epic-Ultra-HD-details, Epic-Ultra-HD-Highlights, Epic-Photo-Same))),
| (Angel_of_Death:1.3), (God-Like_Red_Eyes:1.5), (Cinematic:1.4), (Action_Shot:1.5), (Full_Body_Shot:1.5), |
| (Determined_Battle-Hardened_Expression:1.4), (Sadistic_Grin:1.6), (Narrowed_Determined_Eyes:1.7), |
| (Practical_Light-Armor:1.3), (Intricately_Detailed_Full_Spread_Angel_Wings:1.6), (Roman_Style_Hooded_Cloak:1.4), (Holding_a_Fire_Imbued_Scythe:1.6), |
| (After_the_Battle:1.2), (The_Gates_of_Hell:1.4), (Smoldering_Ruin:1.5), (Volcanic_Aesthetic:1.5), |
| (Ambient_Lighting:1.2), (Ray_Tracing:1.2), (Defined_Shadows:1.2), (Lens_Flare:1.2), (Cascading_Light:1.2), (Particle_Effects:1.2), (Reflective_Surfaces:1.2), |
| (Enhance_Detail:1.2), (Enhance_Lighting:1.2), (Enhance_Lighting_Effects:1.2), (Crisp_Clear_Bold_Lines:1.2), (Highly_Intricate_Detail:1.2), (Enhance_Shadows:1.2), (Define_Layers:1.2), (Depth:1.2), (Sharpen:1.2), (Enhance_Color:1.2), |

Negative Prompt:

(Beyondv4-neg:1.8), badhandv4, bad-hands-5, bad_pictures, bad_prompt_version2-neg, FastNegativeV2, NegfeetV2, verybadimagenegative_v1.3,, Bad_Feet, Bad_Toes, Band_Hands, Bad_Fingers, Missing_Hands, Missing_Feet, Missing_Toes, Missing_Fingers, Extra_Feet, Extra_Hands, Extra_Fingers, Extra_Toes, (Pubic_Hair:2.0), (Pubes:2.0), Extra_Arms, Extra_Legs, Missing_Arms, Missing_Legs, Ugly_Feet, Ugly_Toes, Ugly_Hands, Ugly_Fingers, confusing-poses, 2-in-1, bulging-fingers, unprofessional-joints, unprofessional-bodies, (tongue-pairing:1.8)

Seed:

2363208808

Yeah..! That should be good!

Now I'll be shamelessly using my checkpoint ADD_RC_SM Realistic for these generations. You can grab it too if you'd like to follow along.

So let's do a Vanilla generation of that prompt without DynThres enabled and a CFG scale of 8.

If you are following along, use the following Generation Parameters:

  • Model: ADD_RC_SM v3

  • Sampler: DPM++ SDE Exponential

  • Steps: 70

  • CFG Scale: 8

  • Width: 512

  • Height: 768

Now once you have all that squared away let's generate that image.

Cool. Very Cool. This image already has a decent amount of detail in it thanks to my superior model merge! (Just kidding) But we can give it more.

Let's activate DynThres, set our Mimic Scale to 8 and our Vanilla CFG Scale to 25 and see what we get!

And there you have it! Take a look at these images side by side. Notice that the focus of detail is followed much better with DynThres on the job.

  1. The clothing is much more detailed and textured.

  2. Her expression is much more pronounced.

  3. Her wings are given more depth and detail in the feathering and shadows.

  4. The lighting is much better and fits the aesthetic I was going for.

  5. We've even seen some improvements to her anatomy.

  6. The Cinematic Quality I wanted was applied by giving her that stepping and leaning action.

  7. The fires and associated particle effects I wanted look a ton better.

  8. The background overall looks a lot better and really gives that battle ruined aesthetic.

I could keep going, but I think you get the point.

DynThres has taken my prompt and crammed as much of it into this picture as it possibly can. Well not as much as it possibly can. Let's crank the Vanilla CFG to 30 and the Mimic scale to 18.

This is as much detail as can be crammed into the image before DynThres reaches it's own Threshold. At least with my model. Which leads us to...

Section 3 - Applications to Different 1.x Models:

As we saw above, my model is able to handle a pretty high CFG Scale before it begins to artifact and/or burn. This is because when I was merging my model I was using DynThres for my test generations. This way I could balance on the edge of the threshold while enabling my merge to provide the maximum amount of detail even without DynThres. But this won't always be the case. Some models will be able to take even more abuse from DynThres, but most will take far less. Not knocking other models, just stating facts based on my own testing.

A generally good starting point for any model is going to be a Vanilla Scale of 20 and a Mimic Scale of 7-8. From there you can adjust as needed to find that models "Sweet Spot" and "Absolute Threshold".

There really isn't that much more to say about it. Mess around and go nuts!

Section 4 - Applications to Different Model Types:

(Note: My testing with these models is limited due to the VRAM limitations of my GPU. I'm currently working on building a dedicated SD Rig but parts be expensive and I have a family to take care of. lol.)

SDXL:

So what about SDXL I hear you asking. Well SDXL models will work in much the same way. Some models handle it better than others just like their SD1.x predecessors. The starting point given above applies to these models as well. Just adjust as needed until you've hit that threshold.

SDXL-Turbo:

Now things do change when we start messing with SDXL-Turbo and SDXL- Lightning. These models use a much lower CFG scale to begin with so the use of DynThres has been extremely limited with the Turbo models. Best practice for me has been taking the suggested CFG scale for the model and increasing it my 5-10% pf that number. So if the suggested scale is 7 add. .7-1.4.

SDXL-Lightning:

For SDXL-Lightning I usually just turn it off altogether. I'm sure there is a use case for these models and I'm still doing testing to see what they are. Once I've gotten my data together and feel confident I'm giving good info; I'll update this article accordingly.

Pony:

Pony Models, again, will mostly fall under the original criteria. There are outliers though. So use the 1.x starting point and work your way from there.

Once again; Not much else to be said here.

Section 5 - Conclusion:

In this article I have shown you what DynThres is, what it can do, different use cases, and applications to different model types. Go forth and prosper. lol

In all seriousness though. I hope you found the information here helpful and informative. I do my best to provide you with accurate information in regards to the subject matter and do all my testing independently of anyone else's work.

If you have found this info helpful or have any additional questions, leave a comment below and give the article a like! Simple things like that keep me motivated and I appreciate the interactions.

Until next time!

8

Comments