| 797 | |
| 798 | |
| 799 | def get_num_layer_for_vit(var_name, config): |
| 800 | if (var_name == "module.backbone_module" or var_name.endswith("prompt_embed_kv")) and config.get('lpe_lr', False): |
| 801 | return config.num_layers - 1 |
| 802 | if var_name in ("module.backbone_module", "module.backbone_module.cls_token", "module.backbone_module.mask_token"): |
| 803 | return 0 |
| 804 | elif var_name.startswith("module.backbone_module.patch_embed"): |
| 805 | return 0 |
| 806 | elif var_name.startswith("module.backbone_module") and not (var_name.startswith("module.backbone_module.norm") or |
| 807 | var_name.startswith("module.backbone_module.ln_pre")): |
| 808 | layer_id = int(var_name.split('.')[3]) |
| 809 | return layer_id + 1 |
| 810 | else: |
| 811 | return config.num_layers - 1 |
| 812 | |
| 813 | |
| 814 | class SegmentationRunningMetrics(object): |