From f75559025fc50f0ba719df613167a887698c7282 Mon Sep 17 00:00:00 2001 From: Ekaterina Aidova Date: Wed, 20 Nov 2024 18:33:57 +0400 Subject: [PATCH] fix backward compatibility for case loading preconverted sd without saved safety checker (#1004) --- optimum/intel/openvino/modeling_diffusion.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/optimum/intel/openvino/modeling_diffusion.py b/optimum/intel/openvino/modeling_diffusion.py index 7b3d1c0f45..3ce1cc73f0 100644 --- a/optimum/intel/openvino/modeling_diffusion.py +++ b/optimum/intel/openvino/modeling_diffusion.py @@ -429,6 +429,14 @@ def _from_pretrained( # Check if the module is in a subdirectory if (model_save_path / name).is_dir(): submodels[name] = load_method(model_save_path / name) + # For backward compatibility with models exported using previous optimum version, where safety_checker saving was disabled + elif name == "safety_checker": + logger.warning( + "Pipeline config contains `safety_checker` subcomponent, while `safety_checker` is not available in model directory. " + "`safety_checker` will be disabled. If you want to enable it please set it explicitly to `from_pretrained` method " + "or reexport model with new optimum-intel version" + ) + submodels[name] = None else: submodels[name] = load_method(model_save_path)