Commit 5c1cb926 authored by AUTOMATIC's avatar AUTOMATIC

fix BLIP failing to import depending on configuration

parent 7ba7f4ed
...@@ -83,6 +83,7 @@ class InterrogateModels: ...@@ -83,6 +83,7 @@ class InterrogateModels:
return self.loaded_categories return self.loaded_categories
def load_blip_model(self): def load_blip_model(self):
with paths.Prioritize("BLIP"):
import models.blip import models.blip
files = modelloader.load_models( files = modelloader.load_models(
......
...@@ -38,3 +38,17 @@ for d, must_exist, what, options in path_dirs: ...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment