MCPcopy Create free account
hub / github.com/IDEA-Research/DINO / CocoClassMapper

Class CocoClassMapper

util/utils.py:52–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51
52class CocoClassMapper():
53 def __init__(self) -> None:
54 self.category_map_str = {"1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10, "11": 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, "25": 24, "27": 25, "28": 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, "44": 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, "65": 60, "67": 61, "70": 62, "72": 63, "73": 64, "74": 65, "75": 66, "76": 67, "77": 68, "78": 69, "79": 70, "80": 71, "81": 72, "82": 73, "84": 74, "85": 75, "86": 76, "87": 77, "88": 78, "89": 79, "90": 80}
55 self.origin2compact_mapper = {int(k):v-1 for k,v in self.category_map_str.items()}
56 self.compact2origin_mapper = {int(v-1):int(k) for k,v in self.category_map_str.items()}
57
58 def origin2compact(self, idx):
59 return self.origin2compact_mapper[int(idx)]
60
61 def compact2origin(self, idx):
62 return self.compact2origin_mapper[int(idx)]
63
64def to_device(item, device):
65 if isinstance(item, torch.Tensor):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected