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

Function renew_resnet_paths

diffusers/scripts/convert_if.py:549–568  ·  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

547
548
549def renew_resnet_paths(old_list, n_shave_prefix_segments=0):
550 """
551 Updates paths inside resnets to the new naming scheme (local renaming)
552 """
553 mapping = []
554 for old_item in old_list:
555 new_item = old_item.replace("in_layers.0", "norm1")
556 new_item = new_item.replace("in_layers.2", "conv1")
557
558 new_item = new_item.replace("out_layers.0", "norm2")
559 new_item = new_item.replace("out_layers.3", "conv2")
560
561 new_item = new_item.replace("emb_layers.1", "time_emb_proj")
562 new_item = new_item.replace("skip_connection", "conv_shortcut")
563
564 new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments)
565
566 mapping.append({"old": old_item, "new": new_item})
567
568 return mapping
569
570
571def renew_attention_paths(old_list, n_shave_prefix_segments=0):

Calls 1

shave_segmentsFunction · 0.70

Tested by

no test coverage detected