stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

Support to save full settings in web ui

Open yike5460 opened this issue 1 year ago • 4 comments

Please read the contributing wiki page before submitting a pull request!

If you have a large change, pay special attention to this paragraph:

Before making changes, if you think that your feature will result in more than 100 lines changing, find me and talk to me about the feature you are proposing. It pains me to reject the hard work someone else did, but I won't add everything to the repo, and it's better if the rejection happens before you have to waste time working on the feature.

Otherwise, after making sure you're following the rules described in wiki page, remove this section and continue on.

Describe what this pull request is trying to achieve. What Extra button called "Save settings" in "Settings" tab to save full settings of web ui, including txt2img, img2img, checkpoint merge and training into local file (ui-config.json)

Why We 'd like to provide extension for user to migrate training & inference workload onto cloud instead of on local standalone server, and latest user settings in txt2img, img2img, checkpoint merge and training are needed for cloud service to execute. However, those detailed settings only saved in ui-config.json at initial time. Furthermore, saving full settings in web ui allow user to continue & replicate their env, in case of env is broken or need to be cloned for other team member. Currently we had to parse the html element and extract the setting value using JS, alike some discussions and workaround it's not a optimized way due to: 1) time consuming and error prone to parse all 100+ settings, most workarounds only cover settings in txt2img/img2img; 2) easily outdated since most workaround are implemented by extensions to parse all detailed settings manually, which will easily failed once upstream branch is updated.

How Current, we multiplex the function loadsave/visit to make the change small as possible (20-30 lines), and saved configuration file will overwrite the ui-config.json file.

Additional notes and description of your changes

More technical discussion about your changes go here, plus anything that a maintainer might have to specifically take a look at, or be wary of.

Environment this was tested in

List the environment you have developed / tested this on. As per the contributing page, changes should be able to work on Windows out of the box.

  • OS: Ubuntu
  • Browser: Chrome
  • Graphics card: Tesla T4 Screenshots or videos of your changes Screen Shot 2023-05-04 at 17 31 08

If applicable, screenshots or a video showing off your changes. If it edits an existing UI, it should ideally contain a comparison of what used to be there, before your changes were made.

This is required for anything that touches the user interface.

yike5460 avatar May 04 '23 09:05 yike5460

@AUTOMATIC1111 would you help to check and kindly give me your feedback? we are current using workaround mentioned to pass local settings to the cloud, which is error prone and not maintainable in the future.

yike5460 avatar May 07 '23 14:05 yike5460

If you're making an extension, couldn't it do this?

missionfloyd avatar May 08 '23 00:05 missionfloyd

without your extension loadsave just reads those fields, it does not write them. The way I see it, this button will not do anything useful for the user and its purpose will be unknown.

AUTOMATIC1111 avatar May 08 '23 04:05 AUTOMATIC1111

@AUTOMATIC1111 The modification is directly to ui.py not external extension, loadsave will be used to read all fields, then with open(ui_config_file, "w", encoding="utf8") as file: will write those fields to ui-config.json in root directory.

yike5460 avatar May 08 '23 12:05 yike5460

Please write an instruction from user's standpoint that would demonstrate the usefulness of this Save settings button. As I see it, it does not do anything useful in vanilla webui.

AUTOMATIC1111 avatar May 09 '23 08:05 AUTOMATIC1111

@AUTOMATIC1111 feature to save setting is mainly for user to migrate existing workload from local or standalone server to cloud (AWS SageMaker), including checkpoint merge, model training, txt2img/img2img inferencing etc. Take txt2img for example, the inferencing job will be happened in AWS SageMaker Endpoint instead, thus full sets of parameters (sampling step, CFG scale ...) in WebUI are needed to pass to AWS SageMaker. We implemented a WebUI extension for AWS SageMaker, and full settings in ui-config.json will be parsed & send to AWS SageMaker.

yike5460 avatar May 09 '23 12:05 yike5460

Brief user tutorial: User will first install the extension, extra tab will be installed for user to manager AWS credential, building SD model etc. then user will navigate to original txt2img tab, configure setting like prompts, then save setting, finally click 'SageMaker Inference' button to get the generated image. Thus providing user another alternative to utilize cloud resource without break existing user experience. Mock UI of such extension is shown below image

yike5460 avatar May 09 '23 12:05 yike5460

This is being added to the main repository. Nothing you described and demonstrated in screenshots is present in the main repository. What does the button do for the webui that does not have those extensions?

AUTOMATIC1111 avatar May 09 '23 12:05 AUTOMATIC1111

There are two parts, one is extension for AWS SageMaker that is developed in separate repo, as mock UI shown, PR raised is just to add "Save Setting" button in original WebUI setting tab, and such button will store full setting into local ui-config.json, extension will parse & transform the latest ui-config.json to cloud.

yike5460 avatar May 09 '23 12:05 yike5460

This is being added to the main repository. Nothing you described and demonstrated in screenshots is present in the main repository. What does the button do for the webui that does not have those extensions?

@AUTOMATIC1111 would you please point out the function to save all settings in panel? The only place I can see is here and won't update per user operation. The original requirement to allow cloud service get full settings in webui to execute following inference, training job.

yike5460 avatar May 10 '23 08:05 yike5460

There is no function to write user-inputted values into the ui-config.json file in the webui (nor in this PR). There is only code to add placeholders for default values (ie "img2img/Denoising strength/value": 0.75,).

To save values currently inputted by user in webui you'd need to specify all those elements as the inputs= argument to settings_save.click function call.

AUTOMATIC1111 avatar May 10 '23 09:05 AUTOMATIC1111

@AUTOMATIC1111 So Is there a common data structure/class for us to iterate all setting values in txt2img, img2img, checkpoint merge and training tab, Or we can only assign each specific elements manually? Kindly let me know your feedback for recommended feature implement.

yike5460 avatar May 10 '23 14:05 yike5460

https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/8aa87c564a79965013715d56a5f90d2a34d5d6ee

AUTOMATIC1111 avatar May 10 '23 20:05 AUTOMATIC1111

Brief user tutorial: User will first install the extension, extra tab will be installed for user to manager AWS credential, building SD model etc. then user will navigate to original txt2img tab, configure setting like prompts, then save setting, finally click 'SageMaker Inference' button to get the generated image. Thus providing user another alternative to utilize cloud resource without break existing user experience. Mock UI of such extension is shown below image

我记得可以直接把生成图片请求直接发给sagemaker进行推理

TOM08323049 avatar May 12 '23 08:05 TOM08323049

The functionality for this was added in 1.3.0 so I am closing the PR.

AUTOMATIC1111 avatar May 31 '23 16:05 AUTOMATIC1111

reopen if there's more.

AUTOMATIC1111 avatar May 31 '23 17:05 AUTOMATIC1111