File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -595,6 +595,14 @@ def load_module(name, value):
595595
596596 init_dict = {k : v for k , v in init_dict .items () if load_module (k , v )}
597597
598+ # Special case: safety_checker must be loaded separately when using `from_flax`
599+ if from_flax and "safety_checker" in init_dict and "safety_checker" not in passed_class_obj :
600+ raise NotImplementedError (
601+ "The safety checker cannot be automatically loaded when loading weights `from_flax`."
602+ " Please, pass `safety_checker=None` to `from_pretrained`, and load the safety checker"
603+ " separately if you need it."
604+ )
605+
598606 if len (unused_kwargs ) > 0 :
599607 logger .warning (
600608 f"Keyword arguments { unused_kwargs } are not expected by { pipeline_class .__name__ } and will be ignored."
You can’t perform that action at this time.
0 commit comments