diff --git a/CHANGELOG.md b/CHANGELOG.md index 7139151e5..c6ce174fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,7 @@ And other goodies like multiple *XYZ grid* improvements, additional *Flux Contro - **python 3.12** improved compatibility, automatically handle `setuptools` - **control** persist/reapply units current state on server restart - **video** add option `gradio_skip_video` to avoid gradio issues with displaying generated videos +- add support for manually downloaded diffusers models from huggingface - **ui** - hide token counter until tokens are known - minor ui optimizations diff --git a/modules/modelloader.py b/modules/modelloader.py index 0bd0dda1d..96babbed6 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -258,7 +258,6 @@ def download_diffusers_model(hub_id: str, cache_dir: str = None, download_config def load_diffusers_models(clear=True): - # excluded_models = ['PhotoMaker', 'inswapper_128', 'IP-Adapter'] excluded_models = [] t0 = time.time() place = shared.opts.diffusers_dir @@ -279,11 +278,15 @@ def load_diffusers_models(clear=True): name = name.replace("--", "/") folder = os.path.join(place, folder) friendly = os.path.join(place, name) + if os.path.exists(os.path.join(folder, 'model_index.json')): # direct download of diffusers model + repo = { 'name': name, 'filename': name, 'friendly': friendly, 'folder': folder, 'path': folder, 'hash': '', 'mtime': os.path.getmtime(folder), 'model_info': os.path.join(folder, 'model_info.json'), 'model_index': os.path.join(folder, 'model_index.json') } + diffuser_repos.append(repo) + continue 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 - for snapshot in snapshots: + for snapshot in snapshots: # download using from_pretrained which uses huggingface_hub or huggingface_hub directly and creates snapshot-like structure commit = os.path.join(folder, 'snapshots', snapshot) mtime = os.path.getmtime(commit) info = os.path.join(commit, "model_info.json") diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 9fb6cb33c..e0d212f31 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -362,6 +362,8 @@ class ExtraNetworksPage: item['local_preview'] = f'{base}.{shared.opts.samples_format}' if shared.opts.diffusers_dir in base: match = re.search(r"models--([^/^\\]+)[/\\]", base) + if match is None: + match = re.search(r"models--(.*)", base) base = os.path.join(reference_path, match[1]) model_path = os.path.join(shared.opts.diffusers_dir, match[0]) item['local_preview'] = f'{os.path.join(model_path, match[1])}.{shared.opts.samples_format}'