mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
add builtin gradio themes
This commit is contained in:
@@ -14,8 +14,7 @@ Stuff to be fixed...
|
||||
|
||||
Stuff to be added...
|
||||
|
||||
- Add Gradio base themes: <https://gradio.app/theming-guide/#using-the-theme-builder>
|
||||
- Add gradio theme maker
|
||||
- Add Gradio theme maker
|
||||
- Create new GitHub hooks/actions for CI/CD
|
||||
- Move Restart Server from WebUI to Launch and reload modules
|
||||
- Redo Extensions tab: see <https://vladmandic.github.io/sd-extension-manager/pages/extensions.html>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 97 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 215 KiB |
+2
-2
@@ -310,11 +310,11 @@ function create_theme_element() {
|
||||
|
||||
function preview_theme() {
|
||||
const name = gradioApp().getElementById('setting_gradio_theme').querySelectorAll('span')[1].innerText; // ugly but we want current value without the need to set apply
|
||||
if (name === 'black-orange' || name === 'gradio/default') {
|
||||
if (name === 'black-orange' || name.startsWith('gradio/')) {
|
||||
el = document.getElementById('theme-preview') || create_theme_element();
|
||||
el.style.display = el.style.display === 'block' ? 'none' : 'block';
|
||||
if (name === 'black-orange') el.src = '/file=javascript/black-orange.jpg';
|
||||
else el.src = '/file=javascript/gradio-default.jpg';
|
||||
else el.src = `/file=javascript/${name.replace('/', '-')}.jpg`;
|
||||
} else {
|
||||
fetch('/file=javascript/themes.json')
|
||||
.then((r) => r.json())
|
||||
|
||||
+16
-3
@@ -207,9 +207,11 @@ def list_themes():
|
||||
refresh_themes()
|
||||
with open(os.path.join('javascript', 'themes.json'), mode='r', encoding='utf=8') as f:
|
||||
res = json.loads(f.read())
|
||||
themes = [x['id'] for x in res if x['status'] == 'RUNNING' and 'test' not in x['id'].lower()]
|
||||
builtin = ["black-orange", "gradio/default", "gradio/base", "gradio/glass", "gradio/monochrome", "gradio/soft"]
|
||||
themes = builtin + [x['id'] for x in res if x['status'] == 'RUNNING' and 'test' not in x['id'].lower()]
|
||||
return themes
|
||||
|
||||
|
||||
def refresh_themes():
|
||||
import requests
|
||||
try:
|
||||
@@ -391,7 +393,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": ["black-orange", "gradio/default"] + list_themes()}, refresh=refresh_themes),
|
||||
"gradio_theme": OptionInfo("black-orange", "UI theme", gr.Dropdown, lambda: {"choices": list_themes()}, refresh=refresh_themes),
|
||||
"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"),
|
||||
@@ -685,8 +687,19 @@ def reload_gradio_theme(theme_name=None):
|
||||
global gradio_theme # pylint: disable=global-statement
|
||||
if not theme_name:
|
||||
theme_name = opts.gradio_theme
|
||||
if theme_name == "gradio/default" or theme_name == "black-orange":
|
||||
if theme_name == "black-orange":
|
||||
gradio_theme = gr.themes.Default()
|
||||
elif theme_name.startswith("gradio/"):
|
||||
if theme_name == "gradio/default":
|
||||
gradio_theme = gr.themes.Default()
|
||||
if theme_name == "gradio/base":
|
||||
gradio_theme = gr.themes.Base()
|
||||
if theme_name == "gradio/glass":
|
||||
gradio_theme = gr.themes.Glass()
|
||||
if theme_name == "gradio/monochrome":
|
||||
gradio_theme = gr.themes.Monochrome()
|
||||
if theme_name == "gradio/soft":
|
||||
gradio_theme = gr.themes.Soft()
|
||||
else:
|
||||
try:
|
||||
gradio_theme = gr.themes.ThemeClass.from_hub(theme_name)
|
||||
|
||||
@@ -176,8 +176,9 @@ def check_torch():
|
||||
log.info('nVidia toolkit detected')
|
||||
torch_command = os.environ.get('TORCH_COMMAND', 'torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu118')
|
||||
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.17' if opts.get('cross_attention_optimization', '') == 'xFormers' else 'none')
|
||||
elif shutil.which('rocm-smi') is not None:
|
||||
elif shutil.which('rocminfo') is not None:
|
||||
log.info('AMD toolkit detected')
|
||||
os.environ.setdefault('HSA_OVERRIDE_GFX_VERSION', '10.3.0')
|
||||
torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2')
|
||||
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none')
|
||||
else:
|
||||
@@ -333,7 +334,7 @@ def install_requirements():
|
||||
return
|
||||
log.info('Installing requirements')
|
||||
with open('requirements.txt', 'r', encoding='utf8') as f:
|
||||
lines = [line.strip() for line in f.readlines() if line.strip() != '' and not line.startswith('#')]
|
||||
lines = [line.strip() for line in f.readlines() if line.strip() != '' and not line.startswith('#') and line is not None]
|
||||
for line in lines:
|
||||
install(line)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user