Skip to content

Commit 76ebaed

Browse files
committed
Caching SDXL based models after download step
1 parent e71daff commit 76ebaed

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

gimpopenvino/plugins/openvino_utils/tools/model_manager.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
from tqdm import tqdm
1919
logging.basicConfig(format='%(message)s', level=logging.INFO, stream=sys.stdout)
2020

21+
sys.path.extend([os.path.join(os.path.dirname(os.path.realpath(__file__)), "openvino_common")])
22+
sys.path.extend([os.path.join(os.path.dirname(os.path.realpath(__file__)), "..","tools")])
23+
from models_ov import (stable_diffusion_engine_genai)
24+
25+
26+
2127
# This dictionary is used to populate the drop-down model selection list.
2228
# It's a map from model-id -> model_details.
2329
# 'install_id' is the key used for the 'installable model map'
@@ -538,6 +544,8 @@ def is_model_installed(self, model_id):
538544
config = { "power modes supported": "No",
539545
"best performance" : ["GPU","GPU","GPU"]
540546
}
547+
548+
541549

542550
npu_is_available = self._npu_is_available
543551
npu_arch = self._npu_arch
@@ -546,7 +554,7 @@ def is_model_installed(self, model_id):
546554
config = { "power modes supported": "yes",
547555
"best performance" : ["GPU","GPU","GPU"],
548556
"balanced" : ["GPU","NPU","GPU"],
549-
"best power efficiency" : ["NPU","NPU","GPU"]
557+
"best power efficiency": ["NPU","NPU","GPU"]
550558
}
551559

552560
# Specify the file name
@@ -889,6 +897,8 @@ def _download_model(self, model_id):
889897
config = { "power modes supported": "No",
890898
"best performance" : ["GPU","GPU","GPU"]
891899
}
900+
901+
892902
npu_is_available = self._npu_is_available
893903
npu_arch = self._npu_arch
894904
if npu_is_available:
@@ -920,7 +930,18 @@ def _download_model(self, model_id):
920930

921931
if os.path.isdir(download_folder):
922932
shutil.rmtree(download_folder, ignore_errors=True)
923-
933+
934+
# To cache these models upfront as it takes a lot of time to load.
935+
if "sdxl_turbo" in model_id:
936+
model_name="sdxl_turbo_square"
937+
if "sdxl_base" in model_id:
938+
model_name="sdxl_base_1.0_square"
939+
if "sdxl" in model_id:
940+
stable_diffusion_engine_genai.StableDiffusionEngineGenai(model=full_install_path,model_name=model_name,device=["GPU","GPU","GPU"])
941+
if config["power modes supported"] == "yes":
942+
stable_diffusion_engine_genai.StableDiffusionEngineGenai(model=full_install_path,model_name=model_name,device=["GPU","NPU","GPU"])
943+
stable_diffusion_engine_genai.StableDiffusionEngineGenai(model=full_install_path,model_name=model_name,device=["NPU","NPU","GPU"])
944+
924945
return True
925946

926947
# get 'right-most' folder in the subdir.

0 commit comments

Comments
 (0)