Skip to content

muerrilla/stable-diffusion-NPW

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Negative Prompt Weight

This is a simple extension for the Stable Diffusion Web UI, which allows users to adjust the overall weight of the negative prompt, allowing you to increase or decrease its effect in a new way.

What Does It Do?

Here's a demonstration of how it can continously reduce the effect of the negative prompt from what you normally get (on the right, with weight 1.0) to nothing, as if the negative prompt was empty (on the left, with weight 0.0):

Another example plot showing the effect of different weights Prompt: portrait of zimby anton fadeev cyborg propaganda poster
Params: Steps: 30, Sampler: DPM++ SDE Karras, CFG scale: 7.5, Seed: 918, Size: 512x640, Model: deliberate_v2
Negative Prompt: Male

Another example plot showing the effect of different weights Prompt: portrait of zimby anton fadeev cyborg propaganda poster
Params: Steps: 30, Sampler: DPM++ SDE Karras, CFG scale: 7.5, Seed: 918, Size: 512x640, Model: deliberate_v2
Negative Prompt: Female

Why Use This?

This method was originally intended for decreasing the effect of the negative prompt, which is very hard or at times impossible to do with the currently available methods like Better Prompting™, Attention/Emphasis (using the '(prompt:weight)' syntax), Prompt Editing (using the [prompt1:prompt2:when] syntax), etc. But you can also use it with values higher than 1 and it will boost your negative prompt in its own style (you might need to lower your CFG scale a bit if you do that).

Here is the first example compared to using the '(negative prompts: weight)' syntax (i.e. bottom row is (negative prompt:0),(negative prompt:0.25),etc.:

portrait of zimby anton fadeev cyborg propaganda poster-24-male

Please have a look at the examples in the comparisons section if you want to know how it's different from using '(prompt:weight)' and check out the discussion here if you need more context.

Installation

Open SD WebUI > Go to Extensions tab > Go to Available > Press the big button > Find 'Negative Prompt Weight' in the list > Click Install

Or manually clone this repo into your extensions folder:

git clone "https://github.com/muerrilla/stable-diffusion-NPW" extensions/stable-diffusion-NPW

Usage

Screenshot of the slider provided by the extension in UI

After installing, you can find the new parameter "Negative Prompt Weight" in the extentions area of txt2img and img2img tabs.

More Comparisons and Stuff

Here are some comparisons between NPW and Attention/Emphasis. So, top row is using NPW and bottom row is using the (Negative Prompt: weight) syntax with the same weights.

Prompts: a close up portrait of a cyberpunk [knight|lobster], [lobster| ] armour, cyberpunk!, fantasy, elegant, digital painting, artstation, concept art, matte, sharp focus, art by josan gonzalez

Params: Steps: 30, Sampler: DPM++ 2M Karras, CFG scale: 10, Seed: 6, Size: 512x640, Model: deliberate_v2

a close up portrait of a cyberpunk knight-2-red Negative Prompt: red

a close up portrait of a cyberpunk knight-25-samurai pink cg Negative Prompt: samurai pink cg

a close up portrait of a cyberpunk knight-42 Negative Prompt: custom TI embedding

How It's Done

At runtime a new learned conditioning tensor empty_uncond is made from an empty prompt. Then at every step, inside the denoiser callback, the scheduled uncond tensor of the denoiser (which is based on whatever prompt hijinks were passed to the parser) is lerped with the empty_uncond to weaken it's effect. The lerp function can instead be given a parameter bigger than 1, and it will boost the effect of the negative prompt like the CFG scale does for the positive.

About

Negative Prompt Weight: Extension for Stable Diffusion Web UI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published