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

Load YAML settings into GUI #436

Merged
merged 2 commits into from
Sep 3, 2022
Merged

Conversation

JohannesGaessler
Copy link
Contributor

@JohannesGaessler JohannesGaessler commented Sep 1, 2022

I implemented YAML info files for samples.
Subsequently someone else implemented YAML config files.
However, currently there seems to be no way to load these when using the GUI.
The goal of this PR is to implement this feature.

Detailed goals:

  1. Users can restore the default settings without restarting the program.
  2. Users can open a file dialog to open a YAML file that specifies settings and load these into the program.
  3. Optional: users can automatically read in settings from their OS's clipboard.
  4. Optional: users can create more than one config file and switch between them.

I would like feedback regarding the following points:

  1. How important do you judge goals 3 and 4 to be?
  2. Goal 3 would require the addition of a third party package since Python does not seem to natively support reading in the OS's clipboard. Would this be okay? Alternatively there would be a textbox where users manually paste settings. Edit: I just noticed that the recently merged PR did something with the clipboard. I'll look at how it's done there first.
  3. Where in the GUI should the option for loading settings be? So far I've only added an UI element for txt2img and put it between "Sampling method" and "Simple / Advanced" settings. Ideally the location would be the same for all tabs. Since there currently is another PR open a decision on this should perhaps be postponed until the other PR is finalized.

The specific design of the UI elements is not yet finalized and will depend on the implementation goals.

@JohannesGaessler
Copy link
Contributor Author

Given the new GUI how about adding these buttons to the right of "Copy only seed":

  • A button "Paste" to paste settings from the clipboard (need help with how to do this via Javascript). Format can be either YAML or the human-readable format you get by pressing "Copy full parameters".
  • A button "From file..." to load settings from a YAML file, can be used either for config files or the info files accompanying samples.
  • A button "Restore defaults" or "Defaults" to reset settings. Initially I thought you could maybe put this one next to the "Generate" button but if someone were to missclick that would be very frustrating.

If horizontal space is an issue "Copy full parameters" and "Copy only seed" could be shortened to "Copy all" and "Copy seed" (on my screen it should be fine even without shortening).

Functional restore defaults

From file, non-working paste

Working paste settings
@JohannesGaessler
Copy link
Contributor Author

I now consider this ready to merge.

Look of the modified GUI:
Screenshot_20220901_225406

Summary:

  • Loading settings for txt2img implemented. If someone wants loading settings for img2img or anything else they can implement it themselves or wait until I need it.
  • "Restore defaults" button implemented. Simply restores the defaults from when the program was launched.
  • "From file..." button implemented. Opens a file dialog that lets the user select either a YAML info file or a YAML config file to load in settings. I don't know how to write a file picker in JavaScript so the file picker window is always launched on the host machine. You could maybe use the File element from gradio but I think that would take up way too much space and also look confusing,
  • "Paste" button implemented. Reads the content of the clipboard. If the content is a file path, reads YAML from the file path. If the content is in YAML format, simply read it in directly. Otherwise use as prompt. I did not write a parser for the newly added format that you get when you press the copy button. If compatibility is desired the output of the copy button should be changed to YAML instead. I could not get the Javascript code for reading in clipboard contents to work. I use pyperclip instead. If pyperclip is not installed the paste button is simply hidden and a warning is printed. pyperclip always reads the clipboard content of the host machine, not the client.
  • I shortened the descriptions of the newly added buttons for copying parameters and copying seed because otherwise it looked bad on my screens (1440p and 2160p). I did not check the look on smaller screens.
  • I only checked the file picker on Linux. It should be compatible but I recommend checking anyways.

@hlky hlky merged commit 4af33cc into Sygil-Dev:master Sep 3, 2022
jjisnow pushed a commit to jjisnow/stable-diffusion-webui that referenced this pull request Sep 3, 2022
Functional restore defaults

From file, non-working paste

Working paste settings
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