diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0558fdf..a1ae0c998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log for SD.Next +## Update for 2023-09-07 + +Service release with many fixes + ## Update for 2023-09-06 One week later, another large update! diff --git a/extensions-builtin/sd-extension-system-info b/extensions-builtin/sd-extension-system-info index 761cf83c9..83dd4d8f6 160000 --- a/extensions-builtin/sd-extension-system-info +++ b/extensions-builtin/sd-extension-system-info @@ -1 +1 @@ -Subproject commit 761cf83c93d8ac64b212ccd4a93b8efc2eaae305 +Subproject commit 83dd4d8f65511af720ddb034125fe4ac0a46fb18 diff --git a/javascript/ui.js b/javascript/ui.js index 001d4df30..47575c695 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -361,19 +361,21 @@ function create_theme_element() { return el; } -async function preview_theme() { +function previewTheme() { let name = gradioApp().getElementById('setting_gradio_theme').querySelectorAll('input')?.[0].value || ''; - const res = await fetch('/file=html/themes.json'); - const themes = await res.json(); - const theme = themes.find((t) => t.id === name); - if (theme) { - window.open(theme.subdomain, '_blank'); - } else { - const el = document.getElementById('theme-preview') || create_theme_element(); - el.style.display = el.style.display === 'block' ? 'none' : 'block'; - name = name.replace('/', '-'); - el.src = `/file=html/${name}.jpg`; - } + fetch('/file=html/themes.json').then((res) => { + res.json().then((themes) => { + const theme = themes.find((t) => t.id === name); + if (theme) { + window.open(theme.subdomain, '_blank'); + } else { + const el = document.getElementById('theme-preview') || create_theme_element(); + el.style.display = el.style.display === 'block' ? 'none' : 'block'; + name = name.replace('/', '-'); + el.src = `/file=html/${name}.jpg`; + } + }); + }); } async function reconnectUI() { diff --git a/modules/shared.py b/modules/shared.py index fe2ec4e4d..3a8fb74b9 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -248,33 +248,17 @@ def refresh_checkpoints(): import modules.sd_models # pylint: disable=W0621 return modules.sd_models.list_models() + def refresh_vaes(): import modules.sd_vae # pylint: disable=W0621 modules.sd_vae.refresh_vae_list() + def list_samplers(): import modules.sd_samplers # pylint: disable=W0621 modules.sd_samplers.set_samplers() return modules.sd_samplers.all_samplers -def list_builtin_themes(): - files = [os.path.splitext(f)[0] for f in os.listdir('javascript') if f.endswith('.css')] - return files - -def list_themes(): - fn = os.path.join('html', 'themes.json') - if not os.path.exists(fn): - refresh_themes() - if os.path.exists(fn): - with open(fn, mode='r', encoding='utf=8') as f: - res = json.loads(f.read()) - else: - res = [] - list_builtin_themes() - builtin = list_builtin_themes() + ["gradio/default", "gradio/base", "gradio/glass", "gradio/monochrome", "gradio/soft"] - themes = sorted(builtin) + sorted({x['id'] for x in res if x['status'] == 'RUNNING' and 'test' not in x['id'].lower()}, key=str.casefold) - return themes - def temp_disable_extensions(): disabled = [] @@ -290,6 +274,28 @@ def temp_disable_extensions(): return disabled +def list_builtin_themes(): + files = [os.path.splitext(f)[0] for f in os.listdir('javascript') if f.endswith('.css')] + return files + + +def list_themes(): + fn = os.path.join('html', 'themes.json') + if not os.path.exists(fn): + refresh_themes() + if os.path.exists(fn): + with open(fn, mode='r', encoding='utf=8') as f: + res = json.loads(f.read()) + else: + res = [] + builtin = list_builtin_themes() + default = ["gradio/default", "gradio/base", "gradio/glass", "gradio/monochrome", "gradio/soft"] + external = {x['id'] for x in res if x['status'] == 'RUNNING' and 'test' not in x['id'].lower()} + log.info(f'Themes list: builtin={len(builtin)} default={len(default)} external={len(external)}') + themes = sorted(builtin) + sorted(default) + sorted(external, key=str.casefold) + return themes + + def refresh_themes(): import requests try: @@ -297,8 +303,8 @@ def refresh_themes(): if req.status_code == 200: res = req.json() fn = os.path.join('html', 'themes.json') - with open(fn, mode='w', encoding='utf=8') as f: - f.write(json.dumps(res)) + writefile(res, fn) + list_themes() else: log.error('Error refreshing UI themes') except Exception: diff --git a/modules/ui.py b/modules/ui.py index 87c9cbb1b..1c10cb5af 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -1085,7 +1085,7 @@ def create_ui(startup_timer = None): unload_sd_model.click(fn=unload_sd_weights, inputs=[], outputs=[]) reload_sd_model.click(fn=reload_sd_weights, inputs=[], outputs=[]) request_notifications.click(fn=lambda: None, inputs=[], outputs=[], _js='function(){}') - preview_theme.click(fn=None, _js='preview_theme', inputs=[dummy_component], outputs=[dummy_component]) + preview_theme.click(fn=None, _js='previewTheme', inputs=[], outputs=[]) timer.startup.record("ui-settings")