Skip to content
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

Add adetailer to text areas. #220

Closed
wants to merge 1 commit into from

Conversation

Symbiomatrix
Copy link
Contributor

I haven't followed the difference between core and third party or pos / neg down the road, but it seems to be working for me with just these two lines, and I think you have a failsafe for nonexistent areas in getTextAreas?

@DominikDoom
Copy link
Owner

The general idea is correct, but the implementation has a few things wrong:

  • You added it to the core section, which makes it unaffected by the "Active in third party textboxes" setting.
  • ADetailer supports up to 10 different models that each have their own prompts. Your method will only work for the first tab
    • It's also available in the img2img script section, which also isn't looked up here
  • In older (but still relatively recent) versions of Gradio, accordions (the toggleable containers for the scripts) are empty until opened. In that case, the lookup won't find anything since the textboxes don't exist on the page yet.
    • As mentioned, this is less of a problem on the current webui / gradio version, but I'd like to keep a fair bit of backwards compatibility and support for forks that might use different versions.

Luckily, this all already was a problem at some point when introducing Tiled Diffusion / Multidiffusion Upscaler support, and the current system works relatively well for it. This is what the const thirdParty = {...} JSON object is for.

The working solution is something like this, which has support for the accordion issue by setting onDemand and finds all prompts in a compact manner by looking only for the start of the ID instead of the full string (ignoring the _2nd etc. suffixes).

"adetailer-t2i": {
    "base": "#txt2img_script_container",
    "hasIds": true,
    "onDemand": true,
    "selectors": [
        "[id^=script_txt2img_adetailer_ad_prompt] textarea",
        "[id^=script_txt2img_adetailer_ad_negative_prompt] textarea"
    ]
},
"adetailer-i2i": {
    "base": "#img2img_script_container",
    "hasIds": true,
    "onDemand": true,
    "selectors": [
        "[id^=script_img2img_adetailer_ad_prompt] textarea",
        "[id^=script_img2img_adetailer_ad_negative_prompt] textarea"
    ]
}

So I'll close this, but add the above quickly myself.

@Symbiomatrix
Copy link
Contributor Author

Symbiomatrix commented Aug 15, 2023

Oof, you're right, duplicate objects. It's simple enough, granted, but I think it'd be better if there were just one set of controls for each of t2i / i2i, which updated a parameter list in a state variable.

@DominikDoom
Copy link
Owner

I think it'd be better if there were just one set of controls for each of t2i / i2i, which updated a parameter list in a state variable

Can you elaborate? I'm not sure if I get what you mean here.

@Symbiomatrix
Copy link
Contributor Author

Sorry, I meant in adetailer. Your commit works quite well, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants