##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++## Created by: RainbowSecret## Microsoft Research## yuyua@microsoft.com## Copyright (c) 2018#### This source code is licensed under the MIT-style license found in the## LICENSE file in the root directory of this source tree##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++from__future__importabsolute_importfrom__future__importdivisionfrom__future__importprint_functionimportnumpyasnpimportcv2defget_palette(num_cls):""" Returns the color map for visualizing the segmentation mask. Args: num_cls: Number of classes Returns: The color map """n=num_clspalette=[0]*(n*3)forjinrange(0,n):lab=jpalette[j*3+0]=0palette[j*3+1]=0palette[j*3+2]=0i=0whilelab:palette[j*3+0]|=(((lab>>0)&1)<<(7-i))palette[j*3+1]|=(((lab>>1)&1)<<(7-i))palette[j*3+2]|=(((lab>>2)&1)<<(7-i))i+=1lab>>=3returnpalette