diff --git a/TODO.md b/TODO.md index beda77275..b29f25145 100644 --- a/TODO.md +++ b/TODO.md @@ -14,8 +14,7 @@ Stuff to be fixed... Stuff to be added... -- Add Gradio base themes: -- 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 diff --git a/javascript/gradio-base.jpg b/javascript/gradio-base.jpg new file mode 100644 index 000000000..97a29c107 Binary files /dev/null and b/javascript/gradio-base.jpg differ diff --git a/javascript/gradio-glass.jpg b/javascript/gradio-glass.jpg new file mode 100644 index 000000000..984a509bf Binary files /dev/null and b/javascript/gradio-glass.jpg differ diff --git a/javascript/gradio-monochrome.jpg b/javascript/gradio-monochrome.jpg new file mode 100644 index 000000000..ab2134fb4 Binary files /dev/null and b/javascript/gradio-monochrome.jpg differ diff --git a/javascript/gradio-soft.jpg b/javascript/gradio-soft.jpg new file mode 100644 index 000000000..1ba487a7c Binary files /dev/null and b/javascript/gradio-soft.jpg differ diff --git a/javascript/ui.js b/javascript/ui.js index e52f2d6e1..774422b93 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -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()) diff --git a/modules/shared.py b/modules/shared.py index 9b3eb806b..509d3cf38 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -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) diff --git a/setup.py b/setup.py index 025479d99..cf18701c2 100644 --- a/setup.py +++ b/setup.py @@ -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)