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 preset selection to Gradio UI (session based) #1570

Merged
merged 24 commits into from
Mar 15, 2024

Conversation

mashb1t
Copy link
Collaborator

@mashb1t mashb1t commented Dec 23, 2023

This PR implements a preset selection via radio buttons, which only affects the current gradio session and does not change settings globally.
To achieve this, the logic of the recently implemented meta_parser is used to update the elements in gradio. If a preset file doesn't include specific keys mentioned in modules.config.possible_preset_keys, the initial config is used (incl. preset set in args).
Also directly downloads requirements of a specific preset, allowing usage without having to restart the app (very helpful for Colab).

This offers the flexibility to change all preset keys without having to reload the UI while still keeping the preset set on application start as default/fallback.

Improves #1484

uses meta parsing to set presets in user session (UI elements only)
@xhoxye
Copy link
Contributor

xhoxye commented Dec 24, 2023

Thank you so much.
Unfortunately, the format of the preset is partially the same as the format of the meta_parser.
QQ截图20231224085705

"Resolution": "(1152, 896)",---------- "default_aspect_ratio": "896*1152",
"Styles": "['Fooocus V2', 'Fooocus Enhance', 'Fooocus Sharp']",---------------
"default_styles": ["Fooocus V2","Fooocus Masterpiece","SAI Anime","SAI Digital Art","SAI Enhance","SAI Fantasy Art"],
These two toggles were found to have no effect

@mashb1t
Copy link
Collaborator Author

mashb1t commented Dec 24, 2023

Sorry, i do not completely get what you are referring to.
Which two toggles do you mean that have no effect?

As of https://github.com/lllyasviel/Fooocus/tree/main/presets the "turbo" preset is not a default preset and you most likely have created this yourself, please double check the content there.
In general, only keys of the preset mentioned in https://github.com/lllyasviel/Fooocus/blob/main/modules/config.py#L318 will be used to import settings for preset,s so the key "Styles" from the file you mentioned will not be taken into account.

All options from https://github.com/lllyasviel/Fooocus/blob/main/modules/config.py#L318 (except model download) are mapped to their specific meta identifier counterpart, so they can be set using the same logic as the meta prompt parser, which is intended. Nevertheless, there should not be any overlaps between the features which are user facing.

Please elaborate where exactly you have issues and send the content of your turbo.json preset if this one causes issues for you.

@xhoxye
Copy link
Contributor

xhoxye commented Dec 24, 2023

It has nothing to do with turbo, the resolution and style of other default presets cannot be loaded.

@mashb1t
Copy link
Collaborator Author

mashb1t commented Dec 24, 2023

thank you for the feedback, i'll double-check tomorrow

@mashb1t
Copy link
Collaborator Author

mashb1t commented Dec 24, 2023

@xhoxye both resolution and style are now processed correctly + i've also added style sorting after preset load.
Feel free to test again, your feedback is welcome!

@xhoxye
Copy link
Contributor

xhoxye commented Dec 24, 2023

It already loads normally.
There is a small problem, but it has nothing to do with your code, that is, the "default_refiner": "" in realistic.json will cause the task to cannot be started after the switch, and it needs to be modified to "default_refiner": "None" in order to start the task normally.
QQ截图20231224194245
QQ截图20231224194229

@Amit30swgoh

This comment was marked as off-topic.

@mashb1t

This comment was marked as off-topic.

@Amit30swgoh

This comment was marked as off-topic.

@mashb1t

This comment was marked as off-topic.

@peterng1618
Copy link
Contributor

It's working very well for me. Thanks so much!

Here's some feedback:

  • When switching between presets, the Image Number should remain rather than resetting to 1.
  • A new preset option, similar to the initial, should be added to indicate that the current configurations are parsed from the clipboard. This isn't a major issue, but it would clarify the interface.

I'd also like to suggest some new features:

  • An option in the user interface to save the current configurations as a new preset.
  • It would be helpful if tooltips displayed the contents of a preset when you hover over it.
  • It'd be better if the user-inputted prompts (both positive and negative) were kept when switching presets. Only the preset's default prompts get appended or removed. This is just my own pref, and I understand others might think differently.

Thanks again!

@mashb1t
Copy link
Collaborator Author

mashb1t commented Jan 2, 2024

@peterng1618 all good ideas, but let's keep this MR simple and extend the functionality after it has been merged.

useful for cloud provisioning to prevent model switches and keep models loaded
@xhoxye

This comment was marked as off-topic.

@mashb1t

This comment was marked as resolved.

@xhoxye

This comment was marked as resolved.

@3Diva
Copy link

3Diva commented Jan 14, 2024

How do you enable the presets? My version of Fooocus looks like this:
presets missing temp flie

@mashb1t
Copy link
Collaborator Author

mashb1t commented Jan 14, 2024

@3Diva this PR is still awaiting review and has not yet been merged. You can already use the feature by checking out the git branch feature/add-preset-selection or main of my fork https://github.com/mashb1t/Fooocus by adding a git remote to your local repo OR you can use it by manually applying the file changes of this PR to your local installation.

@3Diva
Copy link

3Diva commented Jan 14, 2024

@mashb1t Oh thank you for the link, I appreciate it. I'm looking forward to checking out your fork of Fooocus! :D The presets sound like a great idea! I often use LCM models and Turbo models with Fooocus and it can be a pain to set up and change all the settings every time. Having presets for a quick one button enable of those settings would be amazingly cool and SO HELPFUL! 😊

I hope that a preset system gets added to vanilla Fooocus too, even if the creator of it chooses to hide it behind the "Advanced" tab, it would be nice to have presets available in Fooocus.

@mashb1t mashb1t linked an issue Jan 14, 2024 that may be closed by this pull request
# Conflicts:
#	modules/config.py
#	presets/realistic.json
@xhoxye
Copy link
Contributor

xhoxye commented Feb 3, 2024

2.1.864 Could not load "default_overwrite_step" this parameter?

@mashb1t mashb1t added the Size M medium change, isolated, testing with care label Feb 9, 2024
# Conflicts:
#	args_manager.py
#	launch.py
#	modules/config.py
#	modules/meta_parser.py
#	webui.py
@mashb1t mashb1t changed the base branch from main to develop March 15, 2024 20:01
@mashb1t mashb1t merged commit 4a44be3 into lllyasviel:develop Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size M medium change, isolated, testing with care
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to create an image by selecting a preset in the browser Switch preset without restarting the app
5 participants