diff options
author | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-08-06 03:06:46 +0000 |
---|---|---|
committer | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-08-06 03:33:20 +0000 |
commit | e9c591b10194a866f1e508899047aca6681c90dc (patch) | |
tree | 6bc1fd8c0ac9bd82d35a57679fde780e252ab4e9 /modules/shared.py | |
parent | c6278c15a81bf65efb65ded50368972a920cc198 (diff) | |
download | stable-diffusion-webui-gfx803-e9c591b10194a866f1e508899047aca6681c90dc.tar.gz stable-diffusion-webui-gfx803-e9c591b10194a866f1e508899047aca6681c90dc.tar.bz2 stable-diffusion-webui-gfx803-e9c591b10194a866f1e508899047aca6681c90dc.zip |
Gradio theme cache
Diffstat (limited to 'modules/shared.py')
-rw-r--r-- | modules/shared.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/shared.py b/modules/shared.py index a99b500b..5e17a4be 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -550,6 +550,7 @@ options_templates.update(options_section(('extra_networks', "Extra Networks"), { options_templates.update(options_section(('ui', "User interface"), {
"localization": OptionInfo("None", "Localization", gr.Dropdown, lambda: {"choices": ["None"] + list(localization.localizations.keys())}, refresh=lambda: localization.list_localizations(cmd_opts.localizations_dir)).needs_reload_ui(),
"gradio_theme": OptionInfo("Default", "Gradio theme", ui_components.DropdownEditable, lambda: {"choices": ["Default"] + gradio_hf_hub_themes}).info("you can also manually enter any of themes from the <a href='https://huggingface.co/spaces/gradio/theme-gallery'>gallery</a>.").needs_reload_ui(),
+ "gradio_themes_cache": OptionInfo(True, "Cache gradio themes locally").info("disable to update the selected Gradio theme"),
"return_grid": OptionInfo(True, "Show grid in results for web"),
"do_not_show_images": OptionInfo(False, "Do not show any images in results for web"),
"send_seed": OptionInfo(True, "Send seed when sending prompt or image to other interface"),
@@ -863,13 +864,17 @@ def reload_gradio_theme(theme_name=None): gradio_theme = gr.themes.Default(**default_theme_args)
else:
try:
- gradio_theme = gr.themes.ThemeClass.from_hub(theme_name)
+ theme_cache_path = os.path.join(script_path, 'tmp', 'gradio_themes', f'{theme_name.replace("/", "_")}.json')
+ if opts.gradio_themes_cache and os.path.exists(theme_cache_path):
+ gradio_theme = gr.themes.ThemeClass.load(theme_cache_path)
+ else:
+ gradio_theme = gr.themes.ThemeClass.from_hub(theme_name)
+ gradio_theme.dump(theme_cache_path)
except Exception as e:
errors.display(e, "changing gradio theme")
gradio_theme = gr.themes.Default(**default_theme_args)
-
class TotalTQDM:
def __init__(self):
self._tqdm = None
|