-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (22 loc) · 704 Bytes
/
Copy pathutils.py
File metadata and controls
31 lines (22 loc) · 704 Bytes
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
import pickle
import numpy as np
def save_pickle(object, filename):
with open(filename, 'wb') as f:
pickle.dump(object, f)
f.close()
def load_pickle(filename):
with open(filename, 'rb') as f:
object = pickle.load(f)
f.close()
return object
def colorize_floorplan(img, classes, cmap):
"""
Colorizes an integer-valued image (multi-class segmentation mask)
based on a pre-defined cmap colorset.
"""
h, w = np.shape(img)
img_c = (np.ones((h, w, 3)) * 255).astype(int)
for cat in classes:
color = np.array(cmap(cat))[:3] * 255
img_c[img == cat, :] = (color).astype(int)
return img_c