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

Function process_weights

diffusers/src/diffusers/loaders/lora_base.py:127–142  ·  view source on GitHub ↗
(adapter_names, weights)

Source from the content-addressed store, hash-verified

125 )
126
127 def process_weights(adapter_names, weights):
128 # Expand weights into a list, one entry per adapter
129 # e.g. for 2 adapters: 7 -> [7,7] ; [3, None] -> [3, None]
130 if not isinstance(weights, list):
131 weights = [weights] * len(adapter_names)
132
133 if len(adapter_names) != len(weights):
134 raise ValueError(
135 f"Length of adapter names {len(adapter_names)} is not equal to the length of the weights {len(weights)}"
136 )
137
138 # Set None values to default of 1.0
139 # e.g. [7,7] -> [7,7] ; [3, None] -> [3,1]
140 weights = [w if w is not None else 1.0 for w in weights]
141
142 return weights
143
144 adapter_names = [adapter_names] if isinstance(adapter_names, str) else adapter_names
145 text_encoder_weights = process_weights(adapter_names, text_encoder_weights)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected