From 6c66228cdebdd46e72ad45c15025c3e12fd62e45 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 18 May 2023 08:17:49 -0400 Subject: [PATCH] fix models dir --- .gitignore | 2 +- modules/modelloader.py | 16 ++-------------- modules/sd_models.py | 2 +- requirements.txt | 2 +- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 1c4049a7b..fe0712400 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # defaults __pycache__ +setup.log /cache.json /config.json /params.txt -/setup.log /styles.csv /ui-config.json /user.css diff --git a/modules/modelloader.py b/modules/modelloader.py index 831de6631..09a3a3f3e 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -1,4 +1,3 @@ -import glob import os import shutil import importlib @@ -21,20 +20,11 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None @return: A list of paths containing the desired model(s) """ output = [] - try: places = [] - - if command_path is not None and command_path != model_path: - pretrained_path = os.path.join(command_path, 'experiments/pretrained_models') - if os.path.exists(pretrained_path): - print(f"Appending path: {pretrained_path}") - places.append(pretrained_path) - elif os.path.exists(command_path): - places.append(command_path) - places.append(model_path) - + if command_path is not None and command_path != model_path and os.path.isdir(command_path): + places.append(command_path) for place in places: for full_path in shared.walk_files(place, allowed_extensions=ext_filter): if os.path.islink(full_path) and not os.path.exists(full_path): @@ -44,7 +34,6 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None continue if full_path not in output: output.append(full_path) - if model_url is not None and len(output) == 0: if download_name is not None: from basicsr.utils.download_util import load_file_from_url @@ -52,7 +41,6 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None output.append(dl) else: output.append(model_url) - except Exception: pass diff --git a/modules/sd_models.py b/modules/sd_models.py index 2db6ee587..125206bb7 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -97,7 +97,7 @@ def checkpoint_tiles(): def list_models(): global model_path # pylint: disable=global-statement - model_path = shared.opts.ckpt_dir + model_path = shared.cmd_opts.models_dir checkpoints_list.clear() checkpoint_aliases.clear() model_list = modelloader.load_models(model_path=model_path, model_url=None, command_path=shared.opts.ckpt_dir, ext_filter=[".ckpt", ".safetensors"], download_name=None, ext_blacklist=[".vae.ckpt", ".vae.safetensors"]) diff --git a/requirements.txt b/requirements.txt index b064b4587..b72c02bf9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,6 @@ kornia lark lmdb lpips -numpy omegaconf open-clip-torch opencv-contrib-python @@ -54,6 +53,7 @@ diffusers==0.16.1 einops==0.4.1 gradio==3.29.0 numexpr==2.8.4 +numpy==1.24.3 pandas==1.5.3 protobuf==3.20.3 pytorch_lightning==1.9.4