MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / text_encoder_mlp_modules

Function text_encoder_mlp_modules

diffusers/src/diffusers/models/lora.py:55–66  ·  view source on GitHub ↗
(text_encoder)

Source from the content-addressed store, hash-verified

53
54
55def text_encoder_mlp_modules(text_encoder):
56 mlp_modules = []
57
58 if isinstance(text_encoder, (CLIPTextModel, CLIPTextModelWithProjection)):
59 for i, layer in enumerate(text_encoder.text_model.encoder.layers):
60 mlp_mod = layer.mlp
61 name = f"text_model.encoder.layers.{i}.mlp"
62 mlp_modules.append((name, mlp_mod))
63 else:
64 raise ValueError(f"do not know how to get mlp modules for: {text_encoder.__class__.__name__}")
65
66 return mlp_modules
67
68
69def adjust_lora_scale_text_encoder(text_encoder, lora_scale: float = 1.0):

Calls

no outgoing calls

Tested by

no test coverage detected