mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
add theme mode toggle
This commit is contained in:
+2
-1
@@ -402,6 +402,7 @@ options_templates.update(options_section(('extra_networks', "Extra Networks"), {
|
||||
|
||||
options_templates.update(options_section(('ui', "User interface"), {
|
||||
"gradio_theme": OptionInfo("black-orange", "UI theme", gr.Dropdown, lambda: {"choices": list_themes()}, refresh=refresh_themes),
|
||||
"theme_style": OptionInfo("Auto", "Theme mode", gr.Radio, {"choices": ["Auto", "Dark", "Light"]}),
|
||||
"return_grid": OptionInfo(True, "Show grid in results for web"),
|
||||
"return_mask": OptionInfo(False, "For inpainting, include the greyscale mask in results for web"),
|
||||
"return_mask_composite": OptionInfo(False, "For inpainting, include masked composite in results for web"),
|
||||
@@ -660,7 +661,7 @@ def reload_gradio_theme(theme_name=None):
|
||||
except:
|
||||
log.error("Theme download error accessing HuggingFace")
|
||||
gradio_theme = gr.themes.Default(**default_font_params)
|
||||
log.info(f'Loading UI theme: {theme_name}')
|
||||
log.info(f'Loading UI theme: name={theme_name} style={opts.theme_style}')
|
||||
|
||||
|
||||
class TotalTQDM:
|
||||
|
||||
@@ -167,7 +167,10 @@ class EmbeddingDatabase:
|
||||
emb = next(iter(param_dict.items()))[1]
|
||||
# diffuser concepts
|
||||
elif type(data) == dict and type(next(iter(data.values()))) == torch.Tensor:
|
||||
assert len(data.keys()) == 1, 'embedding file has multiple terms in it'
|
||||
if len(data.keys()) != 1:
|
||||
shared.log.warning(f"Embedding file has multiple terms in it: {filename}")
|
||||
shared.log.warning(f"Skipping embedding: {filename}")
|
||||
return
|
||||
|
||||
emb = next(iter(data.values()))
|
||||
if len(emb.shape) == 1:
|
||||
@@ -192,15 +195,12 @@ class EmbeddingDatabase:
|
||||
def load_from_dir(self, embdir):
|
||||
if not os.path.isdir(embdir.path):
|
||||
return
|
||||
|
||||
for root, _dirs, fns in os.walk(embdir.path, followlinks=True):
|
||||
for fn in fns:
|
||||
try:
|
||||
fullfn = os.path.join(root, fn)
|
||||
|
||||
if os.stat(fullfn).st_size == 0:
|
||||
continue
|
||||
|
||||
self.load_from_file(fullfn, fn)
|
||||
except Exception as e:
|
||||
errors.display(e, f'embedding load {fn}')
|
||||
|
||||
+7
-17
@@ -1319,10 +1319,10 @@ def create_ui():
|
||||
with gr.Blocks(analytics_enabled=False) as settings_interface:
|
||||
with gr.Row():
|
||||
settings_submit = gr.Button(value="Apply settings", variant='primary', elem_id="settings_submit")
|
||||
defaults_submit = gr.Button(value="Restore defaults", variant='primary', elem_id="defaults_submit")
|
||||
restart_submit = gr.Button(value="Restart server", variant='primary', elem_id="restart_submit")
|
||||
shutdown_submit = gr.Button(value="Shutdown server", variant='primary', elem_id="shutdown_submit")
|
||||
preview_theme = gr.Button(value="Preview theme", variant='primary', elem_id="settings_preview_theme")
|
||||
defaults_submit = gr.Button(value="Restore defaults", variant='primary', elem_id="defaults_submit")
|
||||
unload_sd_model = gr.Button(value='Unload checkpoint', variant='primary', elem_id="sett_unload_sd_model")
|
||||
reload_sd_model = gr.Button(value='Reload checkpoint', variant='primary', elem_id="sett_reload_sd_model")
|
||||
# reload_script_bodies = gr.Button(value='Reload scripts', variant='primary', elem_id="settings_reload_script_bodies")
|
||||
@@ -1392,18 +1392,6 @@ def create_ui():
|
||||
_js='function(){}'
|
||||
)
|
||||
|
||||
"""
|
||||
def reload_scripts():
|
||||
modules.scripts.reload_script_body_only()
|
||||
reload_javascript() # need to refresh the html page
|
||||
|
||||
reload_script_bodies.click(
|
||||
fn=reload_scripts,
|
||||
inputs=[],
|
||||
outputs=[]
|
||||
)
|
||||
"""
|
||||
|
||||
preview_theme.click(
|
||||
fn=None,
|
||||
_js='preview_theme',
|
||||
@@ -1651,11 +1639,13 @@ def html_head():
|
||||
|
||||
def html_body():
|
||||
body = ''
|
||||
# inline = f"{localization.localization_js(shared.opts.localization)};"
|
||||
inline = ''
|
||||
if cmd_opts.theme is not None:
|
||||
inline += f"set_theme('{cmd_opts.theme}');"
|
||||
elif opts.gradio_theme == 'black-orange':
|
||||
if opts.theme_style != 'Auto':
|
||||
if opts.gradio_theme == 'black-orange':
|
||||
modules.shared.log.info('Theme does not support custom mode')
|
||||
else:
|
||||
inline += f"set_theme('{opts.theme_style.lower()}');"
|
||||
if opts.gradio_theme == 'black-orange':
|
||||
inline += "set_theme('dark');"
|
||||
body += f'<script type="text/javascript">{inline}</script>\n'
|
||||
return body
|
||||
|
||||
Reference in New Issue
Block a user