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

Function renew_attention_paths

scripts/convert_zero123_to_diffusers.py:229–247  ·  view source on GitHub ↗

Updates paths inside attentions to the new naming scheme (local renaming)

(old_list, n_shave_prefix_segments=0)

Source from the content-addressed store, hash-verified

227
228
229def renew_attention_paths(old_list, n_shave_prefix_segments=0):
230 """
231 Updates paths inside attentions to the new naming scheme (local renaming)
232 """
233 mapping = []
234 for old_item in old_list:
235 new_item = old_item
236
237 # new_item = new_item.replace('norm.weight', 'group_norm.weight')
238 # new_item = new_item.replace('norm.bias', 'group_norm.bias')
239
240 # new_item = new_item.replace('proj_out.weight', 'proj_attn.weight')
241 # new_item = new_item.replace('proj_out.bias', 'proj_attn.bias')
242
243 # new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments)
244
245 mapping.append({"old": old_item, "new": new_item})
246
247 return mapping
248
249
250def convert_ldm_unet_checkpoint(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected