vladmandic / automatic

SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models
https://github.com/vladmandic/automatic
GNU Affero General Public License v3.0
5.68k stars 422 forks source link

[Feature]: Provide ability to edit styles #1201

Closed DirtyHamster closed 1 year ago

DirtyHamster commented 1 year ago

Feature description

Is it possible to save each individual style to it's own text file so they can be deleted and removed without having to editing the single larger document and restarting the program? Secondly could they be saved independently for prompt and negative prompt? Currently when I want to delete one I have to go into the file and manually edit it out then restart the program. This could be really more useful such as a common negative prompt across multiple generated images. Sadly it load both at the same time.

As far as I've tested this out I have run 1000 character prompts from the style selection drop down on top of additional prompting.

I don't consider this high priority but it would be nice for ease of use.

Version Platform Description

01:58:08-852798 INFO Version: eaea88a4 Mon May 1 21:03:08 2023 -0400 01:58:10-357110 INFO Latest published version: b2c3bc5aaa9522ddcf2bce55a3746293dd9cef72 2023-05-29T01:26:29Z

brknsoul commented 1 year ago

Relevance: https://github.com/vladmandic/automatic/discussions/1189

Workaround: being a .csv file, you can open this in Google Sheets, Excel, etc and edit it there.

vladmandic commented 1 year ago

saving them separately is a workaround, what we need is a full styles editor

Aptronymist commented 1 year ago

saving them separately is a workaround, what we need is a full styles editor

Already gave you one! ;-)

vladmandic commented 1 year ago

it looks promising, but i also gave a feedback - triggering git operations from within an extension, especially with questionable flags is not really best approach:

also updates should be handled by core repo - imagine if each extension did its own checks all the time?

2023-05-29 13:55:51,281 | sd | ERROR | middleware | API error: GET: http://127.0.0.1:7860/better-styles-api/v1/check-for-updates?ts=1685382951273 {'error': 'CalledProcessError', 'detail': '', 'body': '', 'errors': "Command '['git', 'log', '--pretty=%(describe:tags)', '-n', '1']' returned non-zero exit status 1."}
CalledProcessError: Command '['git', 'log', '--pretty=%(describe:tags)', '-n', '1']' returned non-zero exit status 1.
Aptronymist commented 1 year ago

it looks promising, but i also gave a feedback - triggering git operations from within an extension, especially with questionable flags is not really best approach:

also updates should be handled by core repo - imagine if each extension did its own checks all the time?

2023-05-29 13:55:51,281 | sd | ERROR | middleware | API error: GET: http://127.0.0.1:7860/better-styles-api/v1/check-for-updates?ts=1685382951273 {'error': 'CalledProcessError', 'detail': '', 'body': '', 'errors': "Command '['git', 'log', '--pretty=%(describe:tags)', '-n', '1']' returned non-zero exit status 1."}
CalledProcessError: Command '['git', 'log', '--pretty=%(describe:tags)', '-n', '1']' returned non-zero exit status 1.

Right, but... it's not mine to fix. You wouldn't just fork it in?

vladmandic commented 1 year ago

perhaps. in either case, we need a styles editor :)

brknsoul commented 1 year ago

Just a note: I can't seem to get Better Styles to work in vlad's fork. I'm missing the bookmark icon.

I tried @Aptronymist's closed suggestion (https://github.com/eideehi/sd-webui-better-styles/issues/3) of adding const localization = {}; to the beginning of betterStyles.js to no effect.

Aptronymist commented 1 year ago

perhaps. in either case, we need a styles editor :)

I've used it quite a bit now, I think with a little tinkering it would handle that too, it does allow you to edit the style after you hit save, to add/remove/categorize/label it before you actually save, so the functionality is all in there for some editing.

Aptronymist commented 1 year ago

Just a note: I can't seem to get Better Styles to work in vlad's fork. I'm missing the bookmark icon.

I tried @Aptronymist's closed suggestion (eideehi/sd-webui-better-styles#3) of adding const localization = {}; to the beginning of betterStyles.js to no effect.

Oh, I thought Vlad said he fixed that himself? It's not up there next to the networks button?

brknsoul commented 1 year ago

Just a note: I can't seem to get Better Styles to work in vlad's fork. I'm missing the bookmark icon. I tried @Aptronymist's closed suggestion (eideehi/sd-webui-better-styles#3) of adding const localization = {}; to the beginning of betterStyles.js to no effect.

Oh, I thought Vlad said he fixed that himself? It's not up there next to the networks button?

Nope. Check https://github.com/eideehi/sd-webui-better-styles/issues/4 for more info.

Aptronymist commented 1 year ago

Just a note: I can't seem to get Better Styles to work in vlad's fork. I'm missing the bookmark icon. I tried @Aptronymist's closed suggestion (eideehi/sd-webui-better-styles#3) of adding const localization = {}; to the beginning of betterStyles.js to no effect.

Oh, I thought Vlad said he fixed that himself? It's not up there next to the networks button?

Nope. Check eideehi/sd-webui-better-styles#4 for more info.

This is mine at present, working like a charm. var BetterStyles=function(){"use strict";const localization = {};

Oh, also did you try the checkbox to remove the old styles buttons? firefox_vwIcrMfTJS

brknsoul commented 1 year ago

var BetterStyles=function(){"use strict";const localization = {};

Ok, lemme reinstall it and give that a shot.

You could update that issue with your suggestion. Also, you shouldn't close self-opened issues unless there's been a code commit that implements your suggested changes.

Aptronymist commented 1 year ago

Yeah, Vlad said he added something to handle the const localization himself to his code, and I hadn't had any issues with it, so I assumed it was resolved, I'm sorry I closed it. Reopened now.

vladmandic commented 1 year ago

i added a global localizations object in js to avoid that problem, but nothing i can do about git checks that extension does internally (and which are failing on my system due to unrecognized syntax)

Aptronymist commented 1 year ago

var BetterStyles=function(){"use strict";const localization = {};

Ok, lemme reinstall it and give that a shot.

You could update that issue with your suggestion. Also, you shouldn't close self-opened issues unless there's been a code commit that implements your suggested changes.

I reopened and updated it with everything I did.

In my case I now have it right after the first var, so like this: var BetterStyles=function(){"use strict";const localization = {}; and make sure to have the "hide original styles" checked in your settings, as well as having 1.2.0 selected. I don't know for sure what fixes what beyond the localization addition, but those are my current settings and it works fine.

brknsoul commented 1 year ago

Editing var BetterStyles=function(){"use strict"; to add const localization = {}; didn't work.

Ticking the "Hide the original Styles" doesn't do anything. The bookmark icon still isn't there, and the old Styles dropdown still exists. o.O

Aptronymist commented 1 year ago

Editing var BetterStyles=function(){"use strict"; to add const localization = {}; didn't work.

Ticking the "Hide the original Styles" doesn't do anything. The bookmark icon still isn't there, and the old Styles dropdown still exists. o.O

Do a full shutdown/restart? Or at least shift-refresh?

brknsoul commented 1 year ago

Doing that now...

no dice.

EDIT: Note that this is on commit 5f1fd7bd

image

image

image

Aptronymist commented 1 year ago

Doing that now...

no dice. image

image

image

Wow, Uh. No idea what to tell you. That was the extent of my magical powers. I'm even using the Better Prompt that person also made, it works too.

brknsoul commented 1 year ago

I wonder if this is the same issue as https://github.com/vladmandic/automatic/issues/823#issuecomment-1552081794

Aptronymist commented 1 year ago

I wonder if this is the same issue as #823 (comment)

What browser are you using? I'm in Firefox.

brknsoul commented 1 year ago

Chrome. I'll dload a portable vers of firefox and give it a shot.

Nope, still not there in Firefox or .. Edge (eww.. i feel dirty ;-) )

Aptronymist commented 1 year ago

Chrome. I'll dload a portable vers of firefox and give it a shot.

Nope, still not there in Firefox or .. Edge (eww.. i feel dirty ;-) )

You should, I feel dirty by association. Try a different theme? I'm currently using the gradio default iirc.

brknsoul commented 1 year ago

Yeah, tested under black-orange and gradio-default (first thing I did. ;-) )

Aptronymist commented 1 year ago

Yeah, tested under black-orange and gradio-default (first thing I did. ;-) )

Hit me up on the discord, I'll do what I can. best to not flood this with something not exactly related.

brknsoul commented 1 year ago

@vladmandic, if you like you can delete all comments (incl. this one) after vladmandic changed the title ~[Feature]: Styles drop down independent files~ [Feature]: Provide ability to edit styles 3 hours ago"

This issue has been fixed, and yet again, I'm an idiot. :-P

DirtyHamster commented 1 year ago

Could something be added so that the style can be applied and run before or after the given prompt. I've been using the current to run semi-scripted NLP prompts it seems to work when run post initial prompt but I thought it might be interesting to be able to run them before the given prompt too.

vladmandic commented 1 year ago

I think that might be going too far for simple styles, that'd going in a direction of dynamic prompts and regex.

There are extensions that do that, but it all seems a bit complex for normal user.

If there is a good proposal thar focuses on simplicity, I'd love to hear it.

DirtyHamster commented 1 year ago

Being able to run it before or after is pretty much as far as I was thinking on that. As it seems to run through the prompts in line number order, so a stricter later addition to say a negative prompt loaded from style over writes the earlier looser one. Same goes for the regular prompt. So positioning can have a fairly large impact on the output.

Not trying to be too complex on it, it would just be nice if it could handle that portion of run before or run after. So someone might run their commonly used quality prompts first, then current prompt in the prompt window, then commonly used style tags at the end.

vladmandic commented 1 year ago

Yes, I get it, but how would you do that without adding more buttons and controls to UI? Every idea comes at usability cost - I really want to figure out how to simplify the UI, not add more knobs in the main panel.

DirtyHamster commented 1 year ago

I'd probably do a context menu select (right click to get to the before or after behavior selection) on the card provided. Base behavior could just default to the normal run after prompt. So it just add in that cards style name as: as style name (before) or style name (after) place that notation in the correct location in the prompt window as a visual indicator at the top or bottom similar to how we'd id a Lora. This could be indicated as a little code block showing the style name with maybe an x for removal or just as text which could be deleted out if warranted.

I agree with you on keeping the UI fairly simple but I also see potential in possibly doing style stack orders of commonly used elements and just having them easily position able around the manually inputted prompt.

I'm going to ponder over it a little but that's my first idea for how it could be done without adding too much to the UI.

vladmandic commented 1 year ago

oh, that would be nice, wouldn't it? and it would require 3 round trips server <-> browser as gradio does not have right click natively, so i'd need to process it on client and then request server to do something, etc...if right clicks were native, a lot of things could be simplified :)

DirtyHamster commented 1 year ago

lol I'm not use to dealing with the restrictions we have. How about using a simple radio button on the individual card to change the behavior...

vladmandic commented 1 year ago

i'm thinking of doing something like adding a wildcard to style. if wildcard is present, thats where prompt goes. if its not, style gets appended to the end. no additional ui controls and you can then use different styles positionally anywhere you want.

DirtyHamster commented 1 year ago

That might work even better. Provided I can call to it in a direct location in a prompt and potentially use multiples of them. :D

Some of my longer prompts are kind of layed out like this:

photo of scene:((" ("Cinematic medium angle shot":1) WITH (((dramatic soft lighting))), (" "foreground is similar to background, (attractive_female:1) on midground platform wearing (dress:1),(stockings:0.5), is (pi_p:1) in (scmg:1)), (scbg:1)"

"pi_p:( character expression description ) WHILE ( actionable like a pose )"

scbg:("in background:(("2.5d:0.25), simple [("art deco architectural elements"):(art neuvo architectural elements):35], "good use of frame padding", "good depth of field")):35")

IN scmg:(" description code for dress goes here using IF dress: ( on dress:( describes portions of the dress))")

I'm not even sure why it works but it works one of the ones I have picks necklines, sleeves, bodice, waistline, and skirt types. I could slap that wildcard into the portion for on dress or similar and that would be really handy.

vladmandic commented 1 year ago

Daaamn. It would be interesting to enable debug output and see what all that ends up as once it's gone through prompt parser and scheduler...

DirtyHamster commented 1 year ago

I can give you a full copy of the prompt if you want it's 43 lines long and over a 1000 chars. I have like 50 versions of it from how many times I've broken it.. From what I kind of gather it pulls the info from the end of the prompt and then re applies it with some bleed over to the top portion of the prompt. I started messing around with it when I noticed you could do in and on background calls so I just tried applying it to other objects in the prompt which seems to work.

These have 0 post processing going on btw it's just straight to 1440x810

02650-1268-_)) _daringly cinematic_, _dark moody sensual_, _elegantly sexy_, _viscerally sexualized_, lewd high quality professional photog

02643-1270-_)) _daringly cinematic_, _dark moody sensual_, _elegantly sexy_, _viscerally sexualized_, lewd high quality professional photog

02797-1279-_)) _daringly cinematic_, _dark moody sensual_, _elegantly sexy_, _viscerally sexualized_, lewd high quality professional photog

vladmandic commented 1 year ago

I'll show you how to get the output yourself tomorrow (I've added diag to the code, just need to enable it), it might be useful to actually see what goes on with those prompts internally.

DirtyHamster commented 1 year ago

Thanks, That would probably really be useful. Mostly I've just been looking really closely at the images for repeatable patterns for the bleed overs. Sometimes I'll find the little bit of bleed over on a clothing strap or a door frame and can make an adjustment to contain it. I've found that quotes, commas, parenthesis, all matter as does placement in the prompt.

Like this like often causes bleed over issues on the rest of the image: ("art deco architectural elements"):(art neuvo architectural elements):35 such as calling that after the scmg: call it ends up inside of that tag.

vladmandic commented 1 year ago

ok, done, set env variable SD_PROMPT_DEBUG to any non-null value and you'll get the output like this:

09:27:03-894507 INFO     Prompt parse-attention: Full parser [['photo of scene', 1.0], ['Cinematic medium angle shot" WITH', 1.2100000000000002], ['dramatic soft lighting', 1.6105100000000008], ['foreground is similar to background, attractive_female on midground platform wearing dress', 1.3310000000000004], ['stockings',
                         0.6655000000000002], ['is pi_p in scmg', 1.3310000000000004], ['scbg pi_p', 1.2100000000000002], ['character expression description', 1.3310000000000004], ['WHILE', 1.2100000000000002], ['actionable like a pose', 1.3310000000000004], ['scbg', 1.2100000000000002], ['in background', 1.3310000000000004], ['2.5d',
                         0.36602500000000016], ['simple', 1.4641000000000006], ['art deco architectural elements"', 1.6105100000000008], ['good use of frame padding", "good depth of field"', 1.4641000000000006], ['35"', 1.2100000000000002], ['IN scmg', 1.1], ['description code for dress goes here using IF dress', 1.2100000000000002], ['on
                         dress', 1.3310000000000004], ['describes portions of the dress', 1.4641000000000006]]
vladmandic commented 1 year ago

closing in favor of #800