From aad75846a197b39148269f702d1ce8c36e93b567 Mon Sep 17 00:00:00 2001 From: ErdajtSopjani Date: Fri, 17 May 2024 13:00:13 +0200 Subject: [PATCH 1/3] Converted UnrecognizedYamlConfigEntry to Exception - This results in more limited but more rpedictable results - Finished this TODO --- corenet/options/errors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/corenet/options/errors.py b/corenet/options/errors.py index 8c8eb20..5d58514 100644 --- a/corenet/options/errors.py +++ b/corenet/options/errors.py @@ -6,8 +6,8 @@ from corenet.constants import is_test_env -class UnrecognizedYamlConfigEntry(Warning): - # TODO: consider converting UnrecognizedYamlConfigEntry Warning to an Exception. +class UnrecognizedYamlConfigEntry(Exception): + # Throws exception when a key in yaml config is not recognized by argparser. def __init__(self, key: str) -> None: message = ( f"Yaml config key '{key}' was not recognized by argparser. If you think that you have already added " From 23d7d55ece289375ed9439351b409a56c1d2eb35 Mon Sep 17 00:00:00 2001 From: ErdajtSopjani Date: Fri, 17 May 2024 13:01:44 +0200 Subject: [PATCH 2/3] Cleaner approach to generate _cocostuff_remap_info via generate_cocostuff_remap func - This is a cleaner but more maintainable way to generate _cocostuff_remap_info - This function still takes in consideration the skips which can be adjusted for future updates if needed - More readale and maintainable solution --- tools/converter_coco_stuff.py | 191 +++------------------------------- 1 file changed, 15 insertions(+), 176 deletions(-) diff --git a/tools/converter_coco_stuff.py b/tools/converter_coco_stuff.py index af83813..7212590 100644 --- a/tools/converter_coco_stuff.py +++ b/tools/converter_coco_stuff.py @@ -17,184 +17,23 @@ from corenet.utils import logger +# Generates remaps for COCO-Stuff labels to 171 classes. +# Skips some of the labels that are not annotated. +def generate_cocostuff_remap(): + cocostuff_skips = {11, 25, 28, 29, 44, 65, 67, 70, 82, 90, 179, 181} # IDs that are skipped + remap_info = {} + new_id = 0 + for old_id in range(182): + if old_id in cocostuff_skips: + continue + remap_info[old_id] = new_id + new_id += 1 + remap_info[255] = 255 # Special case for the label 255 + return remap_info + # State-of-the-art models use 171 classes for COCO-Stuff. This is because some of the labels defined in # COCO-Stuff are not annotated. So, 182 cocostuff labels are remapped to 171 labels. -_cocostuff_remap_info = { - 0: 0, - 1: 1, - 2: 2, - 3: 3, - 4: 4, - 5: 5, - 6: 6, - 7: 7, - 8: 8, - 9: 9, - 10: 10, - 12: 11, - 13: 12, - 14: 13, - 15: 14, - 16: 15, - 17: 16, - 18: 17, - 19: 18, - 20: 19, - 21: 20, - 22: 21, - 23: 22, - 24: 23, - 26: 24, - 27: 25, - 30: 26, - 31: 27, - 32: 28, - 33: 29, - 34: 30, - 35: 31, - 36: 32, - 37: 33, - 38: 34, - 39: 35, - 40: 36, - 41: 37, - 42: 38, - 43: 39, - 45: 40, - 46: 41, - 47: 42, - 48: 43, - 49: 44, - 50: 45, - 51: 46, - 52: 47, - 53: 48, - 54: 49, - 55: 50, - 56: 51, - 57: 52, - 58: 53, - 59: 54, - 60: 55, - 61: 56, - 62: 57, - 63: 58, - 64: 59, - 66: 60, - 69: 61, - 71: 62, - 72: 63, - 73: 64, - 74: 65, - 75: 66, - 76: 67, - 77: 68, - 78: 69, - 79: 70, - 80: 71, - 81: 72, - 83: 73, - 84: 74, - 85: 75, - 86: 76, - 87: 77, - 88: 78, - 89: 79, - 91: 80, - 92: 81, - 93: 82, - 94: 83, - 95: 84, - 96: 85, - 97: 86, - 98: 87, - 99: 88, - 100: 89, - 101: 90, - 102: 91, - 103: 92, - 104: 93, - 105: 94, - 106: 95, - 107: 96, - 108: 97, - 109: 98, - 110: 99, - 111: 100, - 112: 101, - 113: 102, - 114: 103, - 115: 104, - 116: 105, - 117: 106, - 118: 107, - 119: 108, - 120: 109, - 121: 110, - 122: 111, - 123: 112, - 124: 113, - 125: 114, - 126: 115, - 127: 116, - 128: 117, - 129: 118, - 130: 119, - 131: 120, - 132: 121, - 133: 122, - 134: 123, - 135: 124, - 136: 125, - 137: 126, - 138: 127, - 139: 128, - 140: 129, - 141: 130, - 142: 131, - 143: 132, - 144: 133, - 145: 134, - 146: 135, - 147: 136, - 148: 137, - 149: 138, - 150: 139, - 151: 140, - 152: 141, - 153: 142, - 154: 143, - 155: 144, - 156: 145, - 157: 146, - 158: 147, - 159: 148, - 160: 149, - 161: 150, - 162: 151, - 163: 152, - 164: 153, - 165: 154, - 166: 155, - 167: 156, - 168: 157, - 169: 158, - 170: 159, - 171: 160, - 172: 161, - 173: 162, - 174: 163, - 175: 164, - 176: 165, - 177: 166, - 178: 167, - 179: 168, - 180: 169, - 181: 170, - # 255 is not a label and is ignored during training. - 255: 255, -} - +_cocostuff_remap_info = generate_cocostuff_remap() def remove_unannotated_mask_labels(src_path: str, dst_path: str) -> None: """Remap cocostuff labels. From 9a044b420007973bcdfaeca5e50038aaca96a2e6 Mon Sep 17 00:00:00 2001 From: Erdajt Sopjani <120386306+ErdajtSopjani@users.noreply.github.com> Date: Tue, 28 May 2024 20:38:24 +0200 Subject: [PATCH 3/3] Updated cocostuff_remap skips - Updated and corrected cocostuff_skips Co-authored-by: yanzi --- tools/converter_coco_stuff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/converter_coco_stuff.py b/tools/converter_coco_stuff.py index 7212590..7c9d844 100644 --- a/tools/converter_coco_stuff.py +++ b/tools/converter_coco_stuff.py @@ -20,7 +20,7 @@ # Generates remaps for COCO-Stuff labels to 171 classes. # Skips some of the labels that are not annotated. def generate_cocostuff_remap(): - cocostuff_skips = {11, 25, 28, 29, 44, 65, 67, 70, 82, 90, 179, 181} # IDs that are skipped + cocostuff_skips = {11, 25, 28, 29, 44, 65, 67, 68, 70, 82, 90} # IDs that are skipped remap_info = {} new_id = 0 for old_id in range(182):