-
-
Notifications
You must be signed in to change notification settings - Fork 441
Add Option to Evaluate Dynamic Prompts #1694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
In my rush to create this feature, I missed the existence of the actual dynamicprompts project (MIT licensed) that drives the parsing of the other various plugins and instead recreated my own version from scratch. Here is the handling of structured wildcard files (json and yaml). I'm sure my own implementation is not as robust as this purpose-built library, so I will need to investigate when I get more time. |
It's generally not possible to have dependencies for the plugin - it runs inside Krita's embedded python. I also feel like it's perhaps a bit overkill (or a lot) - I can see the usefulness of Do you use all of it? Or can there be a "90% of the value with 10% of the code" kind of deal? |
Regarding where substitution happens, these are the stages:
Note that Dynamic prompt evaluation could be applied in step 2 - this would also allow adding the result to job metadata.
|
|
I think it's just handling of
In some cases positive prompt can affect only parts of the image while style prompt affects the whole image.
Regions are just prompts that affect certain part of the image. No I don't think state needs to be shared between region prompts.
Personally I don't see the point, negative prompts have limited use. Doesn't stop some people from going ham on them though... |
Okay, moving it to prepare() works as you said, but the job info is still showing the full prompt with template syntax instead of the final evaluated text. What would I need to modify to capture it properly in the job history? EDIT: Found this issue. model.py stores the positive prompt prior to prepare() and uses that stored value for the job info. Should I do this in model.py instead? EDIT2:
|
2f3d56e
to
18678be
Compare
Okay, I think I finally got it working well in process_regions. I added another string member to the Region and RootRegion classes to avoid modifying the original positive property directly and forcing a UI update with the evaluated text. Then in process_regions, I evaluate the root and all regions and I use the evaluated positive property instead, making sure to clear the evaluation before returning from the function, so that the next generation starts from scratch. |
I'm not so happy with storing it in regions, or storing it at all (except maybe in metadata). The rough idea is:
I'd like to avoid state if possible. Dynamic prompt evaluation belongs into (2.) IMO, so it should run on
Live mode: I don't see dynamic prompts being useful there, so wouldn't overthink it. If a use case pops up later it can always be adapted. If you do want to use them in live mode, they should probably be tied to the seed (same seed always generates same dynamic prompt). Job metadata: This is tricky because the stored prompt is used a) for information how this image was generated and b) to recover the original prompt (right click, copy prompt). In the end I can imagine both the evaluated and original prompt being useful here. Note that storing the prompt before |
90b7f37
to
fd3c71d
Compare
fd3c71d
to
630f547
Compare
Refactored text module to move all the dynamic prompt evaluation out to its own file and split it up even further to put wildcard handling in its own file as well. This wildcard module may need to be expanded in the future to handle structured wildcard files (json and yaml), but that would require a ton of rework to how wildcard files are handled, so I'm not going down that road right now. I also refactored the code as desired to be much more concise without breaking anything. Next step is to investigate more on where to put the actual evaluation while still being able to capture it in the job history. Without that info, there is no indication to the user what values were chosen. |
Feature: Dynamic Prompts
Additions
Limitations: