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

feat: allow "Script" dropdown control #33

Closed
wants to merge 3 commits into from

Conversation

wywywywy
Copy link
Contributor

A simple change to allow controlling the "Script" dropdown.

Example configs:

    "default": {
        "script_list": "None"
    },
    "SD Upscale": {
        "script_list": "SD upscale",
        "img2img_steps": 30,
        "img2img_denoising_strength": 0.2
    },

@Zyin055
Copy link
Owner

Zyin055 commented Apr 23, 2023

This does not work as you expect it to.

There is JavaScript tied to the scripts dropdown that expands/collapses the script HTML section. Simply selecting the value in the dropdown does not trigger the JavaScript. The same problem exists with the Hires fix checkbox, which required extra code to trigger. You can see this in config_presets.js: function config_preset_dropdown_change(). The same thing would need to be applied here if you want this functionality to work.

But this also opens up the door to supporting the components within the scripts. Perhaps the suggestion you made in #34 would be a solution for that so all the components don't clog up the UI when creating a new preset. Basically make a new file that the user can edit for a custom list of component IDs, then show that in the config preset creation UI below the normal components. Would you like to try making that?

@wywywywy
Copy link
Contributor Author

So dropdown boxes seem to work differently to checkboxes, and this change I'm proposing actually works without change the javascript. I've been testing it all day on both Firefox and Chrome.

@Zyin055
Copy link
Owner

Zyin055 commented Apr 23, 2023

I'm using Edge and changing the Script dropdown does not display the scripts body.

@wywywywy
Copy link
Contributor Author

I tested in Edge and also another 2 computers, but didn't see the problem you're describing.

Anyway, I've updated the JS. But seeing as it doesn't happen on my end, can you give it a try please.

@Zyin055
Copy link
Owner

Zyin055 commented Apr 26, 2023

Doesn't work. Upon further inspection, I don't think this particular problem is solvable.

Each script body in the HTML does not have a unique selector that corresponds to the script dropdown values, so it's impossible to know which script body corresponds to which script dropdown value. Since we can't target the precise element we can't show it when appropriate.

The script bodies are in the same order they appear in the script dropdown, but this doesn't help either. I briefly looked into the nth-child() selector but that wouldn't work because other extensions, such as ControlNet and DynamicPrompts, inject their HTML here which would screw it up.

@Zyin055
Copy link
Owner

Zyin055 commented Apr 28, 2023

This works now after I updated to the latest A1111 commit (March 29). Looks like they changed how the Gradio dropdown HTML works. I'm busy with other stuff right now so I'll look into it more later.

@Zyin055
Copy link
Owner

Zyin055 commented Apr 28, 2023

So they bumped the Gradio version up to 3.23 AUTOMATIC1111/stable-diffusion-webui@4697def on March 25 which changes how Gradio dropdowns work. One effect of this is that the dropdown values cannot be set via JavaScript anymore, but changing them via Python triggers any relevant events to be fired.

So today I added new functionality to add any custom elements with an ID in a separate config file. I'll upload it after done playtesting.

Zyin055 added a commit that referenced this pull request Apr 29, 2023
Added new config files for custom tracked components for txt2img and img2img
Added "Add custom fields..." button
Renamed component IDs to start with "script_"
#28 #31 #32 #33 #34
@Zyin055 Zyin055 closed this Apr 29, 2023
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