twri / sdxl_prompt_styler

Custom prompt styler node for SDXL in ComfyUI
MIT License
753 stars 74 forks source link

Separate positive prompt G and L if ' . ' present #2

Closed Danamir closed 1 year ago

Danamir commented 1 year ago

Trying a modification of the behavior of the style parser. After some testing it seems that all the positive template after . should be used as positive prompt L instead of simply pasted at the end of the positive prompt G.

Here is a quick example with the sai-pixel art style with the default behavior :

ComfyUI_00036_

And here is with the proposed fix :

ComfyUI_00035_

As you can see the style is much more effective with the second method. It works for all the templates, it seems that Stability AI expected the part after . to be put as supporting terms.

NB : If you put the supporting term in the L and G prompt, the effect is even stonger, but I think somewhat too strong even. It could be set as an option :

ComfyUI_00040_

Danamir commented 1 year ago

Here is a try with the artstyle-pointillism and artstyle-graffiti styles. The first image of each set is with the default method (not stylized enough), the second with the positive G & L separated, and the last with the repeated L tokens in the G prompt (the effect is too strong IMHO) :

grid-pointillism grid-graffiti

Danamir commented 1 year ago

Added the option to choose the split behavior.

image

WinstonWoof commented 1 year ago

@Danamir

appreaciate you have done your own testing however do you have a link to any diocumentation that supports your assertions please

"After some testing it seems that all the positive template after . should be used as positive prompt L instead of simply pasted at the end of the positive prompt G."

NB I'm more than happy with the current behaviour an I actually use daisy chained Global plus individual Styes to feed through image

Danamir commented 1 year ago

No source for my allegations sadly. 😅

I was only playing with various styles and G & L prompts yesterday and I found that the effects were much more effective with the tokens after the dot in the second prompt. Reading the style formulations it seems much more logical too, as those are small coma separated tokens.

So I thought I'd like to have the option to send those words to the L prompt, G promt, or both. Hence the quick PR.

I guess you could have an approaching effect with multiple nodes, but you still have to split the template on .. Or we could have a separate template for L in the json. 🤔

twri commented 1 year ago

From my understanding is that Stability AI feeds both G and L with the same data. Might have been seen in Scott Detweiler videos. This should also be the way SDXL has been trained. The official workflows from both ComfyUI and SAI also use this workflow.

I agree it's strong but fits the style. That said there's some merit to have the possibility to change the outcome.

We still have to support the existing flow so we might need to have two different versions.

How do you handle the output to the refiner? It only takes one prompt.

Danamir commented 1 year ago

We still have to support the existing flow so we might need to have two different versions.

I think if we leave the input text L optional it could mimic the old behavior. 🤔

How do you handle the output to the refiner? It only takes one prompt.

Right now I only use the G prompt for the refiner. I also tried with only the L, and both G and L, and there wasn't much of a difference.

twri commented 1 year ago

I have created a new advanced styler node which should support this use case, this is in the development branch.

Danamir commented 1 year ago

Thanks, I'll give it a try this weekend.

twri commented 1 year ago

Have you had time testing it?

Danamir commented 1 year ago

Tried it just now. Took me a minute to handle the 4 outputs instead of 3 + combobox, but it's working as intended. I think the develop can be merged into main at this point.

Danamir commented 1 year ago

On a side note I don't really know what to think of negative conditioning text g and l. I sometimes get better results by using only one or the other than both. Ideally I would put the style negative keywords in negative text l as those are generally more "concepts" than descriptive, and use a text input for negative text g to remove unwanted "objets" or more descriptive concepts. 🤔

twri commented 1 year ago

So one can say you use it as a way of controlling the strength of the of the style template? Maybe we could use a selection as in your initial PR to control the split behavior. If you have the time to fix it I'd be more than happy to merge it.

twri commented 1 year ago

Sorry if I was a bit vague, but to the new advanced styler. I don't think we should fiddle with the basic one. :)

Danamir commented 1 year ago

Yes of course, I just modified the advanced node to this :

image

But I think it would be nice to have another selection list to choose if the negative is to be appended or prepended to the existing negative prompt. Sometimes we want to really remove a concept, and the style forcing the negative prompt to be last can be detrimental.

Or simply could we alter the behavior to always put the user negative prompt before the style one ?

twri commented 1 year ago

It's not a bad idea. I thought about it on the simple styler (which I use) this morning how the ordering might affect the result. They way it works now is probably the most sane default since I think the style should have priority but we could try it to see how it works out on the advanced one first.

But then you could also just create a new custom style.

Danamir commented 1 year ago

I tried the modification with a negative style position option, but it felt wonky at use. I reverted the modification.

Sometimes I would want a certain token to be sent to the negative G text, and the style to the negative L. With just this option it's impossible, and it would make the node too complicated to add again another option. I think it's best to leave it as it is now. If I want this behavior I can do it manually with various primitive nodes and a prompt combiner one.

If the node seems ok as it is now, you can do the merge.

twri commented 1 year ago

Thanks! Should be merged into development now. Have to update the documentation before I merge into main.

Danamir commented 1 year ago

I edited the PR with development as destination branch, so you can merge it and close the PR.