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 support for configuring UI defaults #40
Conversation
8b0ad50
to
0a07693
Compare
|
dont think it's possible to set tab good work though, are you going to implement for img2img too? you could use the defaults from code if there's no file? |
|
Could do, however I'm not sure how best to handle it. The toggles have different indices, and you currently set the cfg_scale to 5.0 in img2img but 7.5 in txt2img. Should I move the two img2img loopback toggles to the end (to keep the indices of the rest the same across both) and default cfg_scale for both to 7.5? |
|
why not txt2img.yaml and img2img.yaml? can you add the txt2img.yaml file |
Could do, but in that case should I remove the |
|
up2u i dont see many people using it anyway really as long as it doesnt break anything i dont mind |
|
Just updated it with img2img and gfpgan support. Went for one file with multiple sections. |
webui.py
Outdated
| @@ -680,6 +681,11 @@ def flag(self, flag_data, flag_option=None, flag_index=None, username=None): | |||
|
|
|||
| print("Logged:", filenames[0]) | |||
|
|
|||
| if opt.defaults is not None and os.path.isfile(opt.defaults): | |||
| with open(opt.defaults, "r", encoding="utf8") as f: | |||
| user_defaults = yaml.safe_load(f) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when the user specifies an incorrect file?
You might think it won't happen but there's always a chance of major pebkac so it could
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty much the same thing that happens with the --cli arg currently. It just crashes. I'll add a fallback to defaults if the file can't be parsed at all but I don't know if it's worth doing more validation for this.
webui.py
Outdated
| with open(opt.defaults, "r", encoding="utf8") as f: | ||
| user_defaults = yaml.safe_load(f) | ||
| else: | ||
| user_defaults = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't really ever reach this, but pebkac again, if the user specifies a path that is not a file it will
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they do and it doesn't parse as yaml then the program will just crash currently. If it does parse but doesn't have any relevant keys, they won't overwrite the defaults. The update method merges dicts. Merging with an empty one does nothing essentially.
webui.py
Outdated
| 'Save individual images', | ||
| 'Save grid' | ||
| ] | ||
| txt2img_defaults = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set this on user_defaults if the above pebkac caused issue occurs?
seems good but couple of things to change to stop people breaking things accidentally
|
#44 will have broken your changes, sorry, worth rebasing though because this update is |
dc7cd05
to
1f53987
Compare
Adds support for configuring UI default values using the same configuration file format used for the
--cliparameter. By default it looks for the file inconfigs/webui/webui.yaml. Thetargetparameter is currently unused but could be used to select the default tab, however I don't see an option for that in Gradio.