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,6 +83,7 @@ class InterrogateModels:
|
|||
return self.loaded_categories
|
||||
|
||||
def load_blip_model(self):
|
||||
with paths.Prioritize("BLIP"):
|
||||
import models.blip
|
||||
|
||||
files = modelloader.load_models(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue