diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-01-23 21:24:17 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-01-23 21:24:17 +0000 |
commit | 5c1cb9263f980641007088a37360fcab01761d37 (patch) | |
tree | 3032a035d5e4591d3505a7563089e1b4ca0cb807 | |
parent | 7ba7f4ed6e980051c9c461f514d2ddee43001b7e (diff) | |
download | stable-diffusion-webui-gfx803-5c1cb9263f980641007088a37360fcab01761d37.tar.gz stable-diffusion-webui-gfx803-5c1cb9263f980641007088a37360fcab01761d37.tar.bz2 stable-diffusion-webui-gfx803-5c1cb9263f980641007088a37360fcab01761d37.zip |
fix BLIP failing to import depending on configuration
-rw-r--r-- | modules/interrogate.py | 3 | ||||
-rw-r--r-- | modules/paths.py | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/modules/interrogate.py b/modules/interrogate.py index c252b148..236e6983 100644 --- a/modules/interrogate.py +++ b/modules/interrogate.py @@ -83,7 +83,8 @@ class InterrogateModels: return self.loaded_categories
def load_blip_model(self):
- import models.blip
+ with paths.Prioritize("BLIP"):
+ import models.blip
files = modelloader.load_models(
model_path=os.path.join(paths.models_path, "BLIP"),
diff --git a/modules/paths.py b/modules/paths.py index 4dd03a35..20b3e4d8 100644 --- a/modules/paths.py +++ b/modules/paths.py @@ -38,3 +38,17 @@ for d, must_exist, what, options in path_dirs: else:
sys.path.append(d)
paths[what] = d
+
+
+class Prioritize:
+ def __init__(self, name):
+ self.name = name
+ self.path = None
+
+ def __enter__(self):
+ self.path = sys.path.copy()
+ sys.path = [paths[self.name]] + sys.path
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ sys.path = self.path
+ self.path = None
|