fix BLIP failing to import depending on configuration
This commit is contained in:
parent
7ba7f4ed6e
commit
5c1cb9263f
2 changed files with 16 additions and 1 deletions
|
@ -83,7 +83,8 @@ class InterrogateModels:
|
||||||
return self.loaded_categories
|
return self.loaded_categories
|
||||||
|
|
||||||
def load_blip_model(self):
|
def load_blip_model(self):
|
||||||
import models.blip
|
with paths.Prioritize("BLIP"):
|
||||||
|
import models.blip
|
||||||
|
|
||||||
files = modelloader.load_models(
|
files = modelloader.load_models(
|
||||||
model_path=os.path.join(paths.models_path, "BLIP"),
|
model_path=os.path.join(paths.models_path, "BLIP"),
|
||||||
|
|
|
@ -38,3 +38,17 @@ for d, must_exist, what, options in path_dirs:
|
||||||
else:
|
else:
|
||||||
sys.path.append(d)
|
sys.path.append(d)
|
||||||
paths[what] = 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
|
||||||
|
|
Loading…
Reference in a new issue