-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoc.py
More file actions
48 lines (36 loc) · 1.03 KB
/
Copy pathvoc.py
File metadata and controls
48 lines (36 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def get_bit(num, idx):
if ( num & 2**idx > 0 ):
return 1
else:
return 0
def get_colour_map(N = 256):
palette = []
for i in range(N):
idx= i
r = 0
g = 0
b = 0
for j in range(8):
r_bit = get_bit(idx, 0)
g_bit = get_bit(idx, 1)
b_bit = get_bit(idx, 2)
mul_factor = 2**(7-j)
r_mask = r_bit * mul_factor
g_mask = g_bit * mul_factor
b_mask = b_bit * mul_factor
r = r | r_mask
b = b | b_mask
g = g | g_mask
idx= idx// 8
palette.append(r)
palette.append(g)
palette.append(b)
return palette
def get_label_names():
names = ['__background__',
'aeroplane', 'bicycle', 'bird', 'boat',
'bottle', 'bus', 'car', 'cat', 'chair',
'cow', 'diningtable', 'dog', 'horse',
'motorbike', 'person', 'pottedplant',
'sheep', 'sofa', 'train', 'tvmonitor']
return names