(checkpoint, new_checkpoint, old_prefix, new_prefix, has_skip=False)
| 121 | |
| 122 | |
| 123 | def convert_resnet(checkpoint, new_checkpoint, old_prefix, new_prefix, has_skip=False): |
| 124 | new_checkpoint[f"{new_prefix}.norm1.weight"] = checkpoint[f"{old_prefix}.in_layers.0.weight"] |
| 125 | new_checkpoint[f"{new_prefix}.norm1.bias"] = checkpoint[f"{old_prefix}.in_layers.0.bias"] |
| 126 | new_checkpoint[f"{new_prefix}.conv1.weight"] = checkpoint[f"{old_prefix}.in_layers.2.weight"] |
| 127 | new_checkpoint[f"{new_prefix}.conv1.bias"] = checkpoint[f"{old_prefix}.in_layers.2.bias"] |
| 128 | new_checkpoint[f"{new_prefix}.time_emb_proj.weight"] = checkpoint[f"{old_prefix}.emb_layers.1.weight"] |
| 129 | new_checkpoint[f"{new_prefix}.time_emb_proj.bias"] = checkpoint[f"{old_prefix}.emb_layers.1.bias"] |
| 130 | new_checkpoint[f"{new_prefix}.norm2.weight"] = checkpoint[f"{old_prefix}.out_layers.0.weight"] |
| 131 | new_checkpoint[f"{new_prefix}.norm2.bias"] = checkpoint[f"{old_prefix}.out_layers.0.bias"] |
| 132 | new_checkpoint[f"{new_prefix}.conv2.weight"] = checkpoint[f"{old_prefix}.out_layers.3.weight"] |
| 133 | new_checkpoint[f"{new_prefix}.conv2.bias"] = checkpoint[f"{old_prefix}.out_layers.3.bias"] |
| 134 | |
| 135 | if has_skip: |
| 136 | new_checkpoint[f"{new_prefix}.conv_shortcut.weight"] = checkpoint[f"{old_prefix}.skip_connection.weight"] |
| 137 | new_checkpoint[f"{new_prefix}.conv_shortcut.bias"] = checkpoint[f"{old_prefix}.skip_connection.bias"] |
| 138 | |
| 139 | return new_checkpoint |
| 140 | |
| 141 | |
| 142 | def convert_attention(checkpoint, new_checkpoint, old_prefix, new_prefix, attention_dim=None): |
no outgoing calls
no test coverage detected
searching dependent graphs…