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

Function renew_resnet_paths

scripts/convert_original_audioldm_to_diffusers.py:56–75  ·  view source on GitHub ↗

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

(old_list, n_shave_prefix_segments=0)

Source from the content-addressed store, hash-verified

54
55# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_resnet_paths
56def renew_resnet_paths(old_list, n_shave_prefix_segments=0):
57 """
58 Updates paths inside resnets to the new naming scheme (local renaming)
59 """
60 mapping = []
61 for old_item in old_list:
62 new_item = old_item.replace("in_layers.0", "norm1")
63 new_item = new_item.replace("in_layers.2", "conv1")
64
65 new_item = new_item.replace("out_layers.0", "norm2")
66 new_item = new_item.replace("out_layers.3", "conv2")
67
68 new_item = new_item.replace("emb_layers.1", "time_emb_proj")
69 new_item = new_item.replace("skip_connection", "conv_shortcut")
70
71 new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments)
72
73 mapping.append({"old": old_item, "new": new_item})
74
75 return mapping
76
77
78# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_resnet_paths

Callers 1

Calls 1

shave_segmentsFunction · 0.70

Tested by

no test coverage detected