MCPcopy Create free account
hub / github.com/00why00/JoDiffusion / encode_seg

Function encode_seg

utils/utils.py:106–114  ·  view source on GitHub ↗
(semseg, cmap=None)

Source from the content-addressed store, hash-verified

104 return cmap
105
106def encode_seg(semseg, cmap=None):
107 # we will encode the semseg map with a fixed color map
108 if cmap is None:
109 cmap = color_map()
110 seg_t = semseg.astype(np.uint8)
111 array_seg_t = np.empty((seg_t.shape[0], seg_t.shape[1], seg_t.shape[2], cmap.shape[1]), dtype=cmap.dtype)
112 for class_i in np.unique(seg_t):
113 array_seg_t[seg_t == class_i] = cmap[class_i]
114 return array_seg_t
115
116def decode_seg(array_seg_t, cmap=None):
117 # we will decode the semseg map with a fixed color map

Callers 2

process_maskFunction · 0.90
__call__Method · 0.90

Calls 1

color_mapFunction · 0.85

Tested by

no test coverage detected