Skip to content

Commit f755590

Browse files
authored
fix backward compatibility for case loading preconverted sd without saved safety checker (#1004)
1 parent e3031f0 commit f755590

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

optimum/intel/openvino/modeling_diffusion.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@ def _from_pretrained(
429429
# Check if the module is in a subdirectory
430430
if (model_save_path / name).is_dir():
431431
submodels[name] = load_method(model_save_path / name)
432+
# For backward compatibility with models exported using previous optimum version, where safety_checker saving was disabled
433+
elif name == "safety_checker":
434+
logger.warning(
435+
"Pipeline config contains `safety_checker` subcomponent, while `safety_checker` is not available in model directory. "
436+
"`safety_checker` will be disabled. If you want to enable it please set it explicitly to `from_pretrained` method "
437+
"or reexport model with new optimum-intel version"
438+
)
439+
submodels[name] = None
432440
else:
433441
submodels[name] = load_method(model_save_path)
434442

0 commit comments

Comments
 (0)