MCPcopy Index your code
hub / github.com/huggingface/diffusers / disable_adapters

Method disable_adapters

src/diffusers/loaders/peft.py:595–615  ·  view source on GitHub ↗

r""" Disable all adapters attached to the model and fallback to inference with the base model only. If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT [documentation](https://huggingface.co/docs/peft).

(self)

Source from the content-addressed store, hash-verified

593 )
594
595 def disable_adapters(self) -> None:
596 r"""
597 Disable all adapters attached to the model and fallback to inference with the base model only.
598
599 If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
600 [documentation](https://huggingface.co/docs/peft).
601 """
602 check_peft_version(min_version=MIN_PEFT_VERSION)
603
604 if not self._hf_peft_config_loaded:
605 raise ValueError("No adapter loaded. Please load an adapter first.")
606
607 from peft.tuners.tuners_utils import BaseTunerLayer
608
609 for _, module in self.named_modules():
610 if isinstance(module, BaseTunerLayer):
611 if hasattr(module, "enable_adapters"):
612 module.enable_adapters(enabled=False)
613 else:
614 # support for older PEFT versions
615 module.disable_adapters = True
616
617 def enable_adapters(self) -> None:
618 """

Callers 3

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 2

check_peft_versionFunction · 0.85
enable_adaptersMethod · 0.80

Tested by

no test coverage detected