MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / hook_switcher

Function hook_switcher

utils/misc.py:23–42  ·  view source on GitHub ↗
(model, name)

Source from the content-addressed store, hash-verified

21
22# HACK for evalution
23def hook_switcher(model, name):
24 mappings = {}
25 if name in ['cityscapes_fine_sem_seg_val', 'scannet_21_val_seg', 'scannet_38_val_seg', 'scannet_41_val_seg', 'sunrgbd_37_val_seg', 'bdd10k_val_sem_seg', 'ade20k_full_sem_seg_val']:
26 mappings = {'SEMANTIC_ON': True, 'INSTANCE_ON': False, 'PANOPTIC_ON': False}
27 elif name in ['cityscapes_fine_instance_seg_val', 'pascal_part_val_interactive', 'pascal_part_val', 'pascal_part_train'] or 'seginw' in name:
28 mappings = {'SEMANTIC_ON': False, 'INSTANCE_ON': True, 'PANOPTIC_ON': False}
29 elif name in ['cityscapes_fine_panoptic_val', 'scannet_21_panoptic_val', 'bdd10k_40_panoptic_val']:
30 mappings = {'SEMANTIC_ON': True, 'INSTANCE_ON': False, 'PANOPTIC_ON': True}
31 elif 'coco_2017_val_panoptic_with_sem_seg' in name or name in ['ade20k_panoptic_val', 'coco_2017_test-dev', 'sam_val', 'sam_minival']:
32 mappings = {'SEMANTIC_ON': True, 'INSTANCE_ON': True, 'PANOPTIC_ON': True}
33 else:
34 if name not in ["vlp_val", "vlp_captioning_val", "vlp_val2017", "vlp_captioning_val2017", "imagenet_val", "refcocog_val_google", "phrasecut_val", "phrasecut_test", "refcocop_val_unc", "refcoco_val_unc", "refcocog_val_umd"]:
35 assert False, "dataset switcher is not defined"
36 for key, value in mappings.items():
37 if key == 'SEMANTIC_ON':
38 model.model.semantic_on = value
39 if key == 'INSTANCE_ON':
40 model.model.instance_on = value
41 if key == 'PANOPTIC_ON':
42 model.model.panoptic_on = value
43
44class AverageMeter(object):
45 """Computes and stores the average and current value."""

Callers 1

testMethod · 0.90

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected