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

Function rename_orig_weights

scripts/convert_dance_diffusion_to_diffusers.py:220–235  ·  view source on GitHub ↗
(state_dict)

Source from the content-addressed store, hash-verified

218
219
220def rename_orig_weights(state_dict):
221 new_state_dict = {}
222 for k, v in state_dict.items():
223 if k.endswith("kernel"):
224 # up- and downsample layers, don't have trainable weights
225 continue
226
227 new_k = rename(k)
228
229 # check if we need to transform from Conv => Linear for attention
230 if isinstance(new_k, list):
231 new_state_dict = transform_conv_attns(new_state_dict, new_k, v)
232 else:
233 new_state_dict[new_k] = v
234
235 return new_state_dict
236
237
238def transform_conv_attns(new_state_dict, new_k, v):

Callers 1

mainFunction · 0.85

Calls 2

renameFunction · 0.85
transform_conv_attnsFunction · 0.85

Tested by

no test coverage detected