MCPcopy Create free account
hub / github.com/tensorflow/tfjs-models / createPascalColormap

Function createPascalColormap

deeplab/src/utils.ts:23–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21import {Color, DeepLabInput, Label, Legend, ModelArchitecture, QuantizationBytes, SegmentationData} from './types';
22
23export function createPascalColormap(): Color[] {
24 /**
25 * Generates the colormap matching the Pascal VOC dev guidelines.
26 * The original implementation in Python: https://git.io/fjgw5
27 */
28
29 const pascalColormapMaxEntriesNum = config['DATASET_MAX_ENTRIES']['PASCAL'];
30 const colormap = new Array(pascalColormapMaxEntriesNum);
31 for (let idx = 0; idx < pascalColormapMaxEntriesNum; ++idx) {
32 colormap[idx] = new Array(3);
33 }
34 for (let shift = 7; shift > 4; --shift) {
35 const indexShift = 3 * (7 - shift);
36 for (let channel = 0; channel < 3; ++channel) {
37 for (let idx = 0; idx < pascalColormapMaxEntriesNum; ++idx) {
38 colormap[idx][channel] |= ((idx >> (channel + indexShift)) & 1)
39 << shift;
40 }
41 }
42 }
43 return colormap;
44}
45
46/**
47 * Returns

Callers 1

utils_test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected