MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / attn_processors

Method attn_processors

src/diffusers/models/brushnet.py:534–555  ·  view source on GitHub ↗

r""" Returns: `dict` of attention processors: A dictionary containing all attention processors used in the model with indexed by its weight name.

(self)

Source from the content-addressed store, hash-verified

532 @property
533 # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.attn_processors
534 def attn_processors(self) -> Dict[str, AttentionProcessor]:
535 r"""
536 Returns:
537 `dict` of attention processors: A dictionary containing all attention processors used in the model with
538 indexed by its weight name.
539 """
540 # set recursively
541 processors = {}
542
543 def fn_recursive_add_processors(name: str, module: torch.nn.Module, processors: Dict[str, AttentionProcessor]):
544 if hasattr(module, "get_processor"):
545 processors[f"{name}.processor"] = module.get_processor(return_deprecated_lora=True)
546
547 for sub_name, child in module.named_children():
548 fn_recursive_add_processors(f"{name}.{sub_name}", child, processors)
549
550 return processors
551
552 for name, module in self.named_children():
553 fn_recursive_add_processors(name, module, processors)
554
555 return processors
556
557 # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.set_attn_processor
558 def set_attn_processor(self, processor: Union[AttentionProcessor, Dict[str, AttentionProcessor]]):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected