Updates paths inside resnets to the new naming scheme (local renaming)
(old_list, n_shave_prefix_segments=0)
| 221 | |
| 222 | |
| 223 | def renew_resnet_paths(old_list, n_shave_prefix_segments=0): |
| 224 | """ |
| 225 | Updates paths inside resnets to the new naming scheme (local renaming) |
| 226 | """ |
| 227 | mapping = [] |
| 228 | for old_item in old_list: |
| 229 | new_item = old_item.replace("in_layers.0", "norm1") |
| 230 | new_item = new_item.replace("in_layers.2", "conv1") |
| 231 | |
| 232 | new_item = new_item.replace("out_layers.0", "norm2") |
| 233 | new_item = new_item.replace("out_layers.3", "conv2") |
| 234 | |
| 235 | new_item = new_item.replace("emb_layers.1", "time_emb_proj") |
| 236 | new_item = new_item.replace("skip_connection", "conv_shortcut") |
| 237 | |
| 238 | new_item = new_item.replace("time_stack.", "") |
| 239 | |
| 240 | new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) |
| 241 | |
| 242 | mapping.append({"old": old_item, "new": new_item}) |
| 243 | |
| 244 | return mapping |
| 245 | |
| 246 | |
| 247 | def convert_ldm_unet_checkpoint( |
no test coverage detected