diff --git a/CHANGELOG.md b/CHANGELOG.md index a51426232..3ac992e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log for SD.Next -## Update for 2023-10-31 +## Update for 2023-11-01 *Note*: Pending release of `diffusers==0.22.0` @@ -36,7 +36,6 @@ Some highlights: [OpenVINO](https://github.com/vladmandic/automatic/wiki/OpenVIN for details, see [WiKi](https://github.com/vladmandic/automatic/wiki/ONNX-Runtime) - extend support for [Free-U](https://github.com/ChenyangSi/FreeU) improve generations quality at no cost (other than finding params that work for you) - - updated `diffusers` to 0.22.0 - **General** - add **Lora OFT** support, thanks @antis0007 and @ai-casanova - **Upscalers** @@ -49,8 +48,12 @@ Some highlights: [OpenVINO](https://github.com/vladmandic/automatic/wiki/OpenVIN - new option: *settings -> system paths -> models* can be used to set custom base path for *all* models (previously only as cli option) - remove external clone of items in `/repositories` - - switch core font in default theme to **noto-sans** +- **UI** + - UI tweaks for default themes + - UI switch core font in default theme to **noto-sans** previously default font was simply *system-ui*, but it lead to too much variations between browsers and platforms +- **Packages** + - updated `diffusers` to 0.22.0, `transformers` to 4.34.1 - update **openvino**, thanks @disty0 - update **ipex**, thanks @disty0 - update **directml**, @lshqqytiger @@ -72,6 +75,7 @@ Some highlights: [OpenVINO](https://github.com/vladmandic/automatic/wiki/OpenVIN - fix for base+refiner workflow in diffusers mode: number of steps, diffuser pipe mode - fix for prompt encoder with refiner in diffusers mode - fix prompts-from-file saving incorrect metadata + - fix add/remove extra networks to prompt - fix before-hires step - fix diffusers switch from invalid model - force second requirements check on startup diff --git a/extensions-builtin/sd-webui-controlnet b/extensions-builtin/sd-webui-controlnet index f2aafcf2b..3011ff6e7 160000 --- a/extensions-builtin/sd-webui-controlnet +++ b/extensions-builtin/sd-webui-controlnet @@ -1 +1 @@ -Subproject commit f2aafcf2beb99a03cbdf7db73852228ccd6bd1d6 +Subproject commit 3011ff6e706d3fdd0cc7d2ac8ff0d59020b8f767 diff --git a/installer.py b/installer.py index 72d6ef5e9..165c5b9e5 100644 --- a/installer.py +++ b/installer.py @@ -158,9 +158,12 @@ def print_profile(profile: cProfile.Profile, msg: str): # check if package is installed -def installed(package, friendly: str = None): +def installed(package, friendly: str = None, reload = False, quiet = False): ok = True try: + if reload: + import imp # pylint: disable=deprecated-module + imp.reload(pkg_resources) if friendly: pkgs = friendly.split() else: @@ -183,19 +186,26 @@ def installed(package, friendly: str = None): if len(p) > 1: exact = package_version == p[1] ok = ok and (exact or args.experimental) - if not exact: + if not exact and not quiet: if args.experimental: log.warning(f"Package allowing experimental: {p[0]} {package_version} required {p[1]}") else: log.warning(f"Package wrong version: {p[0]} {package_version} required {p[1]}") else: - log.debug(f"Package version not found: {p[0]}") + if not quiet: + log.debug(f"Package not found: {p[0]}") return ok - except ModuleNotFoundError: - log.debug(f"Package not installed: {pkgs}") + except Exception as e: + log.debug(f"Package error: {pkgs} {e}") return False +def uninstall(package): + if installed(package, package): + log.warning(f'Uninstalling: {package}') + pip(f"uninstall {package} --yes --quiet", ignore=True, quiet=True) + + def pip(arg: str, ignore: bool = False, quiet: bool = False): arg = arg.replace('>=', '==') if not quiet: @@ -357,6 +367,7 @@ def check_torch(): log.debug(f'Torch allowed: cuda={allow_cuda} rocm={allow_rocm} ipex={allow_ipex} diml={allow_directml} openvino={allow_openvino}') torch_command = os.environ.get('TORCH_COMMAND', '') xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none') + install('onnxruntime', 'onnxruntime', ignore=True) if torch_command != '': pass elif allow_cuda and (shutil.which('nvidia-smi') is not None or args.use_xformers or os.path.exists(os.path.join(os.environ.get('SystemRoot') or r'C:\Windows', 'System32', 'nvidia-smi.exe'))): @@ -366,6 +377,7 @@ def check_torch(): else: torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision --index-url https://download.pytorch.org/whl/cu118') xformers_package = os.environ.get('XFORMERS_PACKAGE', '--pre xformers' if opts.get('cross_attention_optimization', '') == 'xFormers' else 'none') + install('onnxruntime-gpu', 'onnxruntime-gpu', ignore=True) elif allow_rocm and (shutil.which('rocminfo') is not None or os.path.exists('/opt/rocm/bin/rocminfo') or os.path.exists('/dev/kfd')): log.info('AMD ROCm toolkit detected') os.environ.setdefault('PYTORCH_HIP_ALLOC_CONF', 'garbage_collection_threshold:0.8,max_split_size_mb:512') @@ -430,6 +442,7 @@ def check_torch(): torchvision_pip = 'https://github.com/Nuullll/intel-extension-for-pytorch/releases/download/v2.0.110%2Bxpu-master%2Bdll-bundle/torchvision-0.15.2a0+fa99a53-cp310-cp310-win_amd64.whl' ipex_pip = 'https://github.com/Nuullll/intel-extension-for-pytorch/releases/download/v2.0.110%2Bxpu-master%2Bdll-bundle/intel_extension_for_pytorch-2.0.110+gitc6ea20b-cp310-cp310-win_amd64.whl' torch_command = os.environ.get('TORCH_COMMAND', f'{pytorch_pip} {torchvision_pip} {ipex_pip}') + install('onnxruntime-openvino', ignore=True) elif allow_openvino and args.use_openvino: log.info('Using OpenVINO') if "linux" in sys.platform: @@ -463,6 +476,7 @@ def check_torch(): pytorch_pip = 'torch==2.1.0' torchvision_pip = 'torchvision==0.16.0 --index-url https://download.pytorch.org/whl/cpu' torch_command = os.environ.get('TORCH_COMMAND', f'{pytorch_pip} {torchvision_pip}') + install('onnxruntime-openvino', 'onnxruntime-openvino', ignore=True) else: machine = platform.machine() if sys.platform == 'darwin': @@ -472,6 +486,7 @@ def check_torch(): torch_command = os.environ.get('TORCH_COMMAND', 'torch-directml') if 'torch' in torch_command and not args.version: install(torch_command, 'torch torchvision') + install('onnxruntime-directml', 'onnxruntime-directml', ignore=True) else: log.info('Using CPU-only Torch') torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision') @@ -525,10 +540,7 @@ def check_torch(): if 'cu118' not in torch.__version__: log.warning(f'Likely incompatible Cuda with: xformers=={xformers.__version__} installed: torch=={torch.__version__} required: torch==2.1.0+cu118 - build xformers manually or downgrade torch') elif not args.experimental and not args.use_xformers: - x = pkg_resources.working_set.by_key.get('xformers', None) - if x is not None: - log.warning(f'Not used, uninstalling: {x}') - pip('uninstall xformers --yes --quiet', ignore=True, quiet=True) + uninstall('xformers') except Exception as e: log.debug(f'Cannot install xformers package: {e}') if opts.get('cuda_compile_backend', '') == 'hidet': @@ -572,7 +584,6 @@ def install_packages(): install(clip_package, 'clip') invisiblewatermark_package = os.environ.get('INVISIBLEWATERMARK_PACKAGE', "git+https://github.com/patrickvonplaten/invisible-watermark.git@remove_onnxruntime_depedency") install(invisiblewatermark_package, 'invisible-watermark') - install('onnxruntime==1.15.1', 'onnxruntime', ignore=True) install('pi-heif', 'pi_heif', ignore=True) tensorflow_package = os.environ.get('TENSORFLOW_PACKAGE', 'tensorflow==2.13.0') install(tensorflow_package, 'tensorflow-rocm' if 'rocm' in tensorflow_package else 'tensorflow', ignore=True) @@ -580,10 +591,7 @@ def install_packages(): if bitsandbytes_package is not None: install(bitsandbytes_package, 'bitsandbytes', ignore=True) elif not args.experimental: - bitsandbytes_package = pkg_resources.working_set.by_key.get('bitsandbytes', None) - if bitsandbytes_package is not None: - log.warning(f'Not used, uninstalling: {bitsandbytes_package}') - pip('uninstall bitsandbytes --yes --quiet', ignore=True, quiet=True) + uninstall('bitsandbytes') if args.profile: print_profile(pr, 'Packages') diff --git a/javascript/amethyst-nightfall.css b/javascript/amethyst-nightfall.css index fad37c4b2..18d296730 100644 --- a/javascript/amethyst-nightfall.css +++ b/javascript/amethyst-nightfall.css @@ -96,8 +96,7 @@ svg.feather.feather-image, .feather .feather-image { display: none } #quicksettings .gr-button-tool { font-size: 1.6rem; box-shadow: none; margin-left: -20px; margin-top: -2px; height: 2.4em; } #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h { display: none; } #save-animation { border-radius: var(--radius-sm) !important; margin-bottom: 16px; background-color: #111111; } -#script_list { padding: 4px; margin-top: 20px; margin-bottom: 20px; } -#settings > div.flex-wrap { width: 15em; } +#script_list { padding: 4px; margin-top: 16px; margin-bottom: 8px; } #tab_extensions table { background-color: #222222; } #txt2img_cfg_scale { min-width: 200px; } #txt2img_checkboxes, #img2img_checkboxes { background-color: transparent; } @@ -232,8 +231,8 @@ svg.feather.feather-image, .feather .feather-image { display: none } --spacing-xxs: 1px; --spacing-xs: 2px; --spacing-sm: 4px; - --spacing-lg: 8px; - --spacing-xl: 10px; + --spacing-lg: 6px; + --spacing-xl: 8px; --radius-xxs: 0; --radius-xs: 0; --radius-md: 0; diff --git a/javascript/black-orange.css b/javascript/black-orange.css index ec0ae03ac..4b23af2f5 100644 --- a/javascript/black-orange.css +++ b/javascript/black-orange.css @@ -115,7 +115,7 @@ svg.feather.feather-image, .feather .feather-image { display: none } #quicksettings .gr-button-tool { font-size: 1.6rem; box-shadow: none; margin-left: -20px; margin-top: -2px; height: 2.4em; } #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h { display: none; } #save-animation { border-radius: var(--radius-sm) !important; margin-bottom: 16px; background-color: #111111; } -#script_list { padding: 4px; margin-top: 20px; margin-bottom: 20px; } +#script_list { padding: 4px; margin-top: 16px; margin-bottom: 8px; } #settings > div.flex-wrap { width: 15em; } #tab_extensions table { background-color: #222222; } #txt2img_cfg_scale { min-width: 200px; } @@ -246,8 +246,8 @@ svg.feather.feather-image, .feather .feather-image { display: none } --spacing-xxs: 1px; --spacing-xs: 2px; --spacing-sm: 4px; - --spacing-lg: 8px; - --spacing-xl: 10px; + --spacing-lg: 6px; + --spacing-xl: 8px; --radius-xxs: 0; --radius-xs: 0; --radius-md: 0; diff --git a/javascript/black-teal.css b/javascript/black-teal.css index 38e008361..f543696e8 100644 --- a/javascript/black-teal.css +++ b/javascript/black-teal.css @@ -31,8 +31,6 @@ --block-title-text-color: var(--neutral-300); --radius-sm: 2px; --radius-lg: 4px; - --spacing-md: 4px; - --spacing-xxl: 6px; --line-sm: 1.2em; --line-md: 1.4em; --text-sm: 12px; @@ -110,13 +108,13 @@ svg.feather.feather-image, .feather .feather-image { display: none } #img2img_label_copy_to_img2img { font-weight: normal; } #txt2img_prompt, #txt2img_neg_prompt, #img2img_prompt, #img2img_neg_prompt { background-color: var(--background-color); box-shadow: 4px 4px 4px 0px #333333 !important; } #txt2img_prompt > label > textarea, #txt2img_neg_prompt > label > textarea, #img2img_prompt > label > textarea, #img2img_neg_prompt > label > textarea { font-size: 1.0em; line-height: 1.4em; } -#txt2img_styles, #img2img_styles { margin-top: -10px; margin-left: -10px; width: 100px; } +#txt2img_styles, #img2img_styles { margin-top: -5px; } #img2img_settings { min-width: calc(2 * var(--left-column)); max-width: calc(2 * var(--left-column)); background-color: #111111; padding-top: 16px; } #interrogate, #deepbooru { margin: 0 0px 10px 0px; max-width: 80px; max-height: 80px; font-weight: normal; font-size: 0.95em; } #quicksettings .gr-button-tool { font-size: 1.6rem; box-shadow: none; margin-left: -20px; margin-top: -2px; height: 2.4em; } #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h { display: none; } #save-animation { border-radius: var(--radius-sm) !important; margin-bottom: 16px; background-color: #111111; } -#script_list { padding: 4px; margin-top: 16px; margin-bottom: 16px; } +#script_list { padding: 4px; margin-top: 16px; margin-bottom: 8px; } #settings > div.flex-wrap { width: 15em; } #settings_search { margin-top: 1em; margin-left: 1em; } #settings_search textarea { padding: 0.5em; height: 2.2em !important; } @@ -238,9 +236,10 @@ textarea[rows="1"] { height: 33px !important; width: 99% !important; padding: 8p --neutral-950: #0b0f19; --spacing-xxs: 1px; --spacing-xs: 2px; - --spacing-sm: 4px; - --spacing-lg: 8px; - --spacing-xl: 10px; + --spacing-sm: 3px; + --spacing-lg: 4px; + --spacing-xl: 5px; + --spacing-xxl: 6px; --radius-xxs: 0; --radius-xs: 0; --radius-md: 0; diff --git a/javascript/invoked.css b/javascript/invoked.css index 833af54b6..684527817 100644 --- a/javascript/invoked.css +++ b/javascript/invoked.css @@ -109,7 +109,7 @@ button.selected {background: var(--button-primary-background-fill);} #quicksettings button {padding: 0 0.5em 0.1em 0.5em;} #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h { display: none; } #save-animation { border-radius: var(--radius-sm) !important; margin-bottom: 16px; background-color: #111111; } -#script_list { padding: 4px; margin-top: 20px; margin-bottom: 20px; } +#script_list { padding: 4px; margin-top: 16px; margin-bottom: 8px; } #settings > div.flex-wrap { width: 15em; } #txt2img_cfg_scale { min-width: 200px; } #txt2img_checkboxes, #img2img_checkboxes { background-color: transparent; } @@ -227,8 +227,8 @@ button.selected {background: var(--button-primary-background-fill);} --spacing-xxs: 1px; --spacing-xs: 2px; --spacing-sm: 4px; - --spacing-lg: 8px; - --spacing-xl: 10px; + --spacing-lg: 6px; + --spacing-xl: 8px; --radius-xxs: 0; --radius-xs: 0; --radius-md: 0; diff --git a/javascript/light-teal.css b/javascript/light-teal.css index 5ccb119b0..cc308decd 100644 --- a/javascript/light-teal.css +++ b/javascript/light-teal.css @@ -31,8 +31,6 @@ --block-title-text-color: var(--neutral-900); --radius-sm: 2px; --radius-lg: 4px; - --spacing-md: 4px; - --spacing-xxl: 8px; --line-sm: 1.2em; --line-md: 1.4em; --text-sm: 12px; @@ -107,13 +105,14 @@ svg.feather.feather-image, .feather .feather-image { display: none } #div.gradio-container { overflow-x: hidden; } #img2img_label_copy_to_img2img { font-weight: normal; } #txt2img_prompt, #txt2img_neg_prompt, #img2img_prompt, #img2img_neg_prompt { background-color: var(--background-color); box-shadow: 4px 4px 4px 0px #333333 !important; } -#txt2img_prompt > label > textarea, #txt2img_neg_prompt > label > textarea, #img2img_prompt > label > textarea, #img2img_neg_prompt > label > textarea { font-size: 1.1rem; } +#txt2img_prompt > label > textarea, #txt2img_neg_prompt > label > textarea, #img2img_prompt > label > textarea, #img2img_neg_prompt > label > textarea { font-size: 1.0em; line-height: 1.4em; } +#txt2img_styles, #img2img_styles { margin-top: -5px; } #img2img_settings { min-width: calc(2 * var(--left-column)); max-width: calc(2 * var(--left-column)); background-color: #111111; padding-top: 16px; } #interrogate, #deepbooru { margin: 0 0px 10px 0px; max-width: 80px; max-height: 80px; font-weight: normal; font-size: 0.95em; } #quicksettings .gr-button-tool { font-size: 1.6rem; box-shadow: none; margin-left: -20px; margin-top: -2px; height: 2.4em; } #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h { display: none; } #save-animation { border-radius: var(--radius-sm) !important; margin-bottom: 16px; background-color: #111111; } -#script_list { padding: 4px; margin-top: 20px; margin-bottom: 20px; } +#script_list { padding: 4px; margin-top: 16px; margin-bottom: 8px; } #settings > div.flex-wrap { width: 15em; } #tab_extensions table { background-color: #222222; } #txt2img_cfg_scale { min-width: 200px; } @@ -297,11 +296,12 @@ svg.feather.feather-image, .feather .feather-image { display: none } --size-9: 64px; --slider_color: None; --slider-color: ; - --spacing-lg: 8px; - --spacing-sm: 4px; - --spacing-xl: 10px; - --spacing-xs: 2px; --spacing-xxs: 1px; + --spacing-xs: 2px; + --spacing-sm: 3px; + --spacing-lg: 4px; + --spacing-xl: 5px; + --spacing-xxl: 6px; --stat-background-fill: linear-gradient(to right, var(--primary-400), var(--primary-600)); --table-border-color: var(--neutral-700); --table-even-background-fill: #222222; diff --git a/javascript/midnight-barbie.css b/javascript/midnight-barbie.css index 9ddb399a0..7049a96b9 100644 --- a/javascript/midnight-barbie.css +++ b/javascript/midnight-barbie.css @@ -101,7 +101,7 @@ svg.feather.feather-image, .feather .feather-image { display: none } #quicksettings .gr-button-tool { font-size: 1.6rem; box-shadow: none; margin-left: -20px; margin-top: -2px; height: 2.4em; } #open_folder_extras, #footer, #style_pos_col, #style_neg_col, #roll_col, #extras_upscaler_2, #extras_upscaler_2_visibility, #txt2img_seed_resize_from_w, #txt2img_seed_resize_from_h { display: none; } #save-animation { border-radius: var(--radius-sm) !important; margin-bottom: 16px; background-color: #111111; } -#script_list { padding: 4px; margin-top: 20px; margin-bottom: 20px; } +#script_list { padding: 4px; margin-top: 16px; margin-bottom: 8px; } #settings > div.flex-wrap { width: 15em; } #tab_extensions table { background-color: #222222; } #txt2img_cfg_scale { min-width: 200px; } @@ -232,8 +232,8 @@ svg.feather.feather-image, .feather .feather-image { display: none } --spacing-xxs: 1px; --spacing-xs: 2px; --spacing-sm: 4px; - --spacing-lg: 8px; - --spacing-xl: 10px; + --spacing-lg: 6px; + --spacing-xl: 8px; --radius-xxs: 0; --radius-xs: 0; --radius-md: 0; diff --git a/javascript/sdnext.css b/javascript/sdnext.css index de6f2a496..8bb9bf876 100644 --- a/javascript/sdnext.css +++ b/javascript/sdnext.css @@ -6,6 +6,7 @@ footer { display: none; } table { overflow-x: auto !important; overflow-y: auto !important; } td { border-bottom: none !important; padding: 0.1em 0.5em !important; } tr { border-bottom: none !important; padding: 0.1em 0.5em !important; } +textarea { overflow-y: auto !important; } /* gradio elements */ .block .padded:not(.gradio-accordion) { padding: 0 !important; margin-right: 0; min-width: 90px !important; } @@ -24,9 +25,9 @@ tr { border-bottom: none !important; padding: 0.1em 0.5em !important; } .gradio-button.secondary-down { background: var(--button-secondary-background-fill); color: var(--button-secondary-text-color); } .gradio-button.secondary-down, .gradio-button.secondary-down:hover { box-shadow: 1px 1px 1px rgba(0,0,0,0.25) inset, 0px 0px 3px rgba(0,0,0,0.15) inset; } .gradio-button.secondary-down:hover { background: var(--button-secondary-background-fill-hover); color: var(--button-secondary-text-color-hover); } -.gradio-button.tool { max-width: min-content; min-width: min-content !important; align-self: end; font-size: 1.4em; color: var(--body-text-color) !important; margin-bottom: var(--spacing-md); } +.gradio-button.tool { max-width: min-content; min-width: min-content !important; align-self: end; font-size: 1.4em; color: var(--body-text-color) !important; margin-bottom: var(--spacing-md); align-self: center; } .gradio-checkbox { margin: 0.75em 1.5em 0 0; align-self: center; } -.gradio-column { min-width: unset; } +.gradio-column { min-width: min(160px, 100%) !important; } .gradio-container { max-width: unset !important; padding: var(--block-label-padding) !important; } .gradio-container .prose a, .gradio-container .prose a:visited{ color: unset; text-decoration: none; } @@ -42,7 +43,7 @@ tr { border-bottom: none !important; padding: 0.1em 0.5em !important; } .gradio-textbox { overflow: visible !important; } .gradio-radio { padding: 0 !important; width: max-content !important; } .gradio-slider { margin-right: var(--spacing-sm) !important; width: max-content !important } -.gradio-slider input[type="number"] { width: 6em; font-size: 0.8rem; height: 20px; margin-left: 0.5em; } +.gradio-slider input[type="number"] { width: 6em; font-size: 0.8rem; height: 16px; text-align: right; } /* custom gradio elements */ .accordion-compact { padding: 8px 0px 4px 0px !important; } @@ -76,7 +77,7 @@ button.custom-button{ border-radius: var(--button-large-radius); padding: var(-- #txt2img_generate_box > button, #img2img_generate_box > button, #txt2img_enqueue, #img2img_enqueue { min-height: 42px; max-height: 42px; line-height: 1em; } #txt2img_generate_line2, #img2img_generate_line2, #txt2img_tools, #img2img_tools { display: flex; } #txt2img_generate_line2 > button, #img2img_generate_line2 > button, #extras_generate_box > button, #txt2img_tools > button, #img2img_tools > button { height: 2em; line-height: 0; font-size: var(--input-text-size); - min-width: unset; display: block !important; margin-left: 0.4em; margin-right: 0.4em; } + min-width: unset; display: block !important; } #txt2img_prompt, #txt2img_neg_prompt, #img2img_prompt, #img2img_neg_prompt { display: contents; } .interrogate-col{ min-width: 0 !important; max-width: fit-content; margin-right: var(--spacing-xxl); } .interrogate-col > button{ flex: 1; } diff --git a/modules/modelloader.py b/modules/modelloader.py index 7625b0ee1..86cfdf3c7 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -245,13 +245,14 @@ def download_diffusers_model(hub_id: str, cache_dir: str = None, download_config return pipeline_dir -def load_diffusers_models(model_path: str, command_path: str = None): +def load_diffusers_models(model_path: str, command_path: str = None, clear=True): t0 = time.time() places = [] places.append(model_path) if command_path is not None and command_path != model_path: places.append(command_path) - diffuser_repos.clear() + if clear: + diffuser_repos.clear() output = [] for place in places: if not os.path.isdir(place): @@ -272,20 +273,21 @@ def load_diffusers_models(model_path: str, command_path: str = None): continue _, name = folder.split("--", maxsplit=1) name = name.replace("--", "/") - snapshots = os.listdir(os.path.join(place, folder, "snapshots")) + folder = os.path.join(place, folder) + friendly = os.path.join(place, name) + snapshots = os.listdir(os.path.join(folder, "snapshots")) if len(snapshots) == 0: shared.log.warning(f"Diffusers folder has no snapshots: location={place} folder={folder} name={name}") continue - commit = snapshots[-1] - folder = os.path.join(place, folder, 'snapshots', commit) - mtime = os.path.getmtime(folder) - info = os.path.join(folder, "model_info.json") - diffuser_repos.append({ 'name': name, 'filename': name, 'path': folder, 'hash': commit, 'mtime': mtime, 'model_info': info }) + commit = os.path.join(folder, 'snapshots', snapshots[-1]) + mtime = os.path.getmtime(commit) + info = os.path.join(commit, "model_info.json") + diffuser_repos.append({ 'name': name, 'filename': name, 'friendly': friendly, 'folder': folder, 'path': commit, 'hash': commit, 'mtime': mtime, 'model_info': info }) if os.path.exists(os.path.join(folder, 'hidden')): continue output.append(name) except Exception as e: - shared.log.error(f"Error analyzing diffusers model: {place}/{folder} {e}") + shared.log.error(f"Error analyzing diffusers model: {folder} {e}") except Exception as e: shared.log.error(f"Error listing diffusers: {place} {e}") shared.log.debug(f'Scanning diffusers cache: {model_path} {command_path} items={len(output)} time={time.time()-t0:.2f}') @@ -293,11 +295,12 @@ def load_diffusers_models(model_path: str, command_path: str = None): def find_diffuser(name: str): - import huggingface_hub as hf - if name in diffuser_repos: - return name + repo = [r for r in diffuser_repos if name == r['name'] or name == r['friendly'] or name == r['path']] + if len(repo) > 0: + return repo['name'] if shared.cmd_opts.no_download: return None + import huggingface_hub as hf hf_api = hf.HfApi() hf_filter = hf.ModelFilter( model_name=name, diff --git a/modules/paths.py b/modules/paths.py index 46dc27a0a..d7a9e8691 100644 --- a/modules/paths.py +++ b/modules/paths.py @@ -18,7 +18,7 @@ config_path = cli.config if os.path.isabs(cli.config) else os.path.join(cli.data try: with open(config_path, 'r', encoding='utf8') as f: config = json.load(f) -except Exception as err: +except Exception: config = {} modules_path = os.path.dirname(os.path.realpath(__file__)) diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index b9b461af9..3207ee147 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -147,9 +147,6 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro shared.state.job = prev_job return imgs - def t(x): - return f"\033[34m{str(tuple(x.shape)).ljust(24)}\033[0m (\033[31mmin {x.amin().item():+.4f}\033[0m / \033[32mmean {x.mean().item():+.4f}\033[0m / \033[33mmax {x.amax().item():+.4f}\033[0m)" - def vae_encode(image, model, full_quality=True): # pylint: disable=unused-variable if shared.state.interrupted or shared.state.skipped: return [] diff --git a/modules/sd_models.py b/modules/sd_models.py index f401ebee0..3dfd4ca01 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -83,7 +83,7 @@ class CheckpointInfo: self.type = ext # self.model_name = os.path.splitext(name.replace("/", "_").replace("\\", "_"))[0] else: # maybe a diffuser - repo = [r for r in modelloader.diffuser_repos if filename == r['filename']] + repo = [r for r in modelloader.diffuser_repos if filename == r['name']] if len(repo) == 0: self.name = relname self.filename = filename @@ -99,8 +99,8 @@ class CheckpointInfo: self.title = self.name if self.shorthash is None else f'{self.name} [{self.shorthash}]' self.path = self.filename self.model_name = os.path.basename(self.name) - # shared.log.debug(f'Checkpoint: type={self.type} name={self.name} filename={self.filename} hash={self.shorthash} title={self.title}') self.metadata = read_metadata_from_safetensors(filename) + # shared.log.debug(f'Checkpoint: type={self.type} name={self.name} filename={self.filename} hash={self.shorthash} title={self.title}') def register(self): checkpoints_list[self.title] = self @@ -162,7 +162,7 @@ def list_models(): ext_filter = [".ckpt", ".safetensors"] model_list = modelloader.load_models(model_path=model_path, model_url=None, command_path=shared.opts.ckpt_dir, ext_filter=ext_filter, download_name=None, ext_blacklist=[".vae.ckpt", ".vae.safetensors"]) if shared.backend == shared.Backend.DIFFUSERS: - model_list += modelloader.load_diffusers_models(model_path=os.path.join(models_path, 'Diffusers'), command_path=shared.opts.diffusers_dir) + model_list += modelloader.load_diffusers_models(model_path=os.path.join(models_path, 'Diffusers'), command_path=shared.opts.diffusers_dir, clear=True) for filename in sorted(model_list, key=str.lower): checkpoint_info = CheckpointInfo(filename) if checkpoint_info.name is not None: diff --git a/modules/sd_samplers_kdiffusion.py b/modules/sd_samplers_kdiffusion.py index 578953740..2141b66de 100644 --- a/modules/sd_samplers_kdiffusion.py +++ b/modules/sd_samplers_kdiffusion.py @@ -23,7 +23,7 @@ try: import importlib k_diffusion = importlib.import_module('modules.k-diffusion.k_diffusion') k_sampling = k_diffusion.sampling -except: +except Exception: pass if k_sampling is None: shared.log.info(f'Path search: {sys.path}') diff --git a/modules/ui.py b/modules/ui.py index 7a629a00a..633aa6f83 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -158,7 +158,7 @@ def create_seed_inputs(tab): random_seed = ToolButton(symbols.random, elem_id=f"{tab}_random_seed", label='Random seed') reuse_seed = ToolButton(symbols.reuse, elem_id=f"{tab}_reuse_seed", label='Reuse seed') with FormRow(visible=True, elem_id=f"{tab}_subseed_row", variant="compact"): - subseed = gr.Number(label='Variation seed', value=-1, elem_id=f"{tab}_subseed", container=True) + subseed = gr.Number(label='Variation', value=-1, elem_id=f"{tab}_subseed", container=True) random_subseed = ToolButton(symbols.random, elem_id=f"{tab}_random_subseed") reuse_subseed = ToolButton(symbols.reuse, elem_id=f"{tab}_reuse_subseed") subseed_strength = gr.Slider(label='Variation strength', value=0.0, minimum=0, maximum=1, step=0.01, elem_id=f"{tab}_subseed_strength") diff --git a/modules/ui_prompt_styles.py b/modules/ui_prompt_styles.py index 56b700a27..c7b7f75d5 100644 --- a/modules/ui_prompt_styles.py +++ b/modules/ui_prompt_styles.py @@ -27,7 +27,7 @@ def save_style(name, prompt, negative_prompt): def delete_style(name): if name == "": - return + return '', '', '' shared.prompt_styles.styles.pop(name, None) shared.prompt_styles.save_styles('') return '', '', '' diff --git a/requirements.txt b/requirements.txt index f7b583b7e..d33559d83 100644 --- a/requirements.txt +++ b/requirements.txt @@ -58,7 +58,8 @@ numba==0.57.1 pandas==1.5.3 protobuf==3.20.3 pytorch_lightning==1.9.4 -transformers==4.30.2 +transformers==4.34.1 +tokenizers==0.14.1 tomesd==0.1.3 urllib3==1.26.15 Pillow==9.5.0 diff --git a/scripts/xyz_grid.py b/scripts/xyz_grid.py index 99730b686..5e5c00938 100644 --- a/scripts/xyz_grid.py +++ b/scripts/xyz_grid.py @@ -393,20 +393,20 @@ class Script(scripts.Script): self.current_axis_options = [x for x in axis_options if type(x) == AxisOption or x.is_img2img == is_img2img] with gr.Row(): with gr.Column(): - with gr.Row(): - x_type = gr.Dropdown(label="X type", choices=[x.label for x in self.current_axis_options], value=self.current_axis_options[0].label, type="index", elem_id=self.elem_id("x_type")) - x_values = gr.Textbox(label="X values", lines=1, elem_id=self.elem_id("x_values")) - x_values_dropdown = gr.Dropdown(label="X values",visible=False,multiselect=True,interactive=True) + with gr.Row(variant='compact'): + x_type = gr.Dropdown(label="X type", container=True, choices=[x.label for x in self.current_axis_options], value=self.current_axis_options[0].label, type="index", elem_id=self.elem_id("x_type")) + x_values = gr.Textbox(label="X values", container=True, lines=1, elem_id=self.elem_id("x_values")) + x_values_dropdown = gr.Dropdown(label="X values", container=True, visible=False, multiselect=True, interactive=True) fill_x_button = ToolButton(value=symbols.fill, elem_id="xyz_grid_fill_x_tool_button", visible=False) - with gr.Row(): - y_type = gr.Dropdown(label="Y type", choices=[x.label for x in self.current_axis_options], value=self.current_axis_options[0].label, type="index", elem_id=self.elem_id("y_type")) - y_values = gr.Textbox(label="Y values", lines=1, elem_id=self.elem_id("y_values")) - y_values_dropdown = gr.Dropdown(label="Y values",visible=False,multiselect=True,interactive=True) + with gr.Row(variant='compact'): + y_type = gr.Dropdown(label="Y type", container=True, choices=[x.label for x in self.current_axis_options], value=self.current_axis_options[0].label, type="index", elem_id=self.elem_id("y_type")) + y_values = gr.Textbox(label="Y values", container=True, lines=1, elem_id=self.elem_id("y_values")) + y_values_dropdown = gr.Dropdown(label="Y values", container=True, visible=False, multiselect=True, interactive=True) fill_y_button = ToolButton(value=symbols.fill, elem_id="xyz_grid_fill_y_tool_button", visible=False) - with gr.Row(): - z_type = gr.Dropdown(label="Z type", choices=[x.label for x in self.current_axis_options], value=self.current_axis_options[0].label, type="index", elem_id=self.elem_id("z_type")) - z_values = gr.Textbox(label="Z values", lines=1, elem_id=self.elem_id("z_values")) - z_values_dropdown = gr.Dropdown(label="Z values",visible=False,multiselect=True,interactive=True) + with gr.Row(variant='compact'): + z_type = gr.Dropdown(label="Z type", container=True, choices=[x.label for x in self.current_axis_options], value=self.current_axis_options[0].label, type="index", elem_id=self.elem_id("z_type")) + z_values = gr.Textbox(label="Z values", container=True, lines=1, elem_id=self.elem_id("z_values")) + z_values_dropdown = gr.Dropdown(label="Z values", container=True, visible=False, multiselect=True, interactive=True) fill_z_button = ToolButton(value=symbols.fill, elem_id="xyz_grid_fill_z_tool_button", visible=False) with gr.Row(): with gr.Column(): diff --git a/wiki b/wiki index 2e3f37151..85730ec4e 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 2e3f3715172ef9b1540d3849fe652a3a51ea8f98 +Subproject commit 85730ec4ee05b4d40229957f41977ea8c09e3795