Skip to content

Commit 9431195

Browse files
author
Roman Donchenko
authored
Merge pull request #2191 from anzhella-pankratova/release_palettes
segmentation_demo.py: add description of color palette file (#2171)
2 parents 6c5ce53 + 864fde7 commit 9431195

File tree

6 files changed

+218
-3
lines changed

6 files changed

+218
-3
lines changed

data/palettes/ade20k_150cl_colors.txt

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
(120, 120, 120) # wall
2+
(180, 120, 120) # building;edifice
3+
( 6, 230, 230) # sky
4+
( 80, 50, 50) # floor;flooring
5+
( 4, 200, 3) # tree
6+
(120, 120, 80) # ceiling
7+
(140, 140, 140) # road;route
8+
(204, 5, 255) # bed
9+
(230, 230, 230) # windowpane;window
10+
( 4, 250, 7) # grass
11+
(224, 5, 255) # cabinet
12+
(235, 255, 7) # sidewalk;pavement
13+
(150, 5, 61) # person;individual;someone;somebody;mortal;soul
14+
(120, 120, 70) # earth;ground
15+
( 8, 255, 51) # door;double
16+
(255, 6, 82) # table
17+
(143, 255, 140) # mountain;mount
18+
(204, 255, 4) # plant;flora;life
19+
(255, 51, 7) # curtain;drape;drapery;mantle;pall
20+
(204, 70, 3) # chair
21+
( 0, 102, 200) # car;auto;automobile;machine;motorcar
22+
(61, 230, 250) # water
23+
(255, 6, 51) # painting;picture
24+
( 11, 102, 255) # sofa;couch;lounge
25+
(255, 7, 71) # shelf
26+
(255, 9, 224) # house
27+
( 9, 7, 230) # sea
28+
(220, 220, 220) # mirror
29+
(255, 9, 92) # rug;carpet;carpeting
30+
(112, 9, 255) # field
31+
( 8, 255, 214) # armchair
32+
( 7, 255, 224) # seat
33+
(255, 184, 6) # fence;fencing
34+
( 10, 255, 71) # desk
35+
(255, 41, 10) # rock;stone
36+
( 7, 255, 255) # wardrobe;closet;press
37+
(224, 255, 8) # lamp
38+
(102, 8, 255) # bathtub;bathing;tub;bath
39+
(255, 61, 6) # railing;rail
40+
(255, 194, 7) # cushion
41+
(255, 122, 8) # base;pedestal;stand
42+
(0, 255, 20) # box
43+
(255, 8, 41) # column;pillar
44+
(255, 5, 153) # signboard;sign
45+
(6, 51, 255) # chest;of;drawers;bureau;dresser
46+
(235, 12, 255) # counter
47+
(160, 150, 20) # sand
48+
( 0, 163, 255) # sink
49+
(140, 140, 140) # skyscraper
50+
(250, 10, 15) # fireplace;hearth;open
51+
( 20, 255, 0) # refrigerator;icebox
52+
( 31, 255, 0) # grandstand;covered;stand
53+
(255, 31, 0) # path
54+
(255, 224, 0) # stairs;steps
55+
(153, 255, 0) # runway
56+
( 0, 0, 255) # case;display;showcase;vitrine
57+
(255, 71, 0) # pool;table;billiard;snooker
58+
( 0, 235, 255) # pillow
59+
( 0, 173, 255) # screen;door
60+
( 31, 0, 255) # stairway;staircase
61+
( 11, 200, 200) # river
62+
(255, 82, 0) # bridge;span
63+
( 0, 255, 245) # bookcase
64+
( 0, 61, 255) # blind;screen
65+
( 0, 255, 112) # coffee;table;cocktail
66+
( 0, 255, 133) # toilet;can;commode;crapper;pot;potty;stool;throne
67+
(255, 0, 0) # flower
68+
(255, 163, 0) # book
69+
(255, 102, 0) # hill
70+
(194, 255, 0) # bench
71+
( 0, 143, 255) # countertop
72+
( 51, 255, 0) # stove;kitchen;range;cooking
73+
( 0, 82, 255) # palm;tree
74+
( 0, 255, 41) # kitchen;island
75+
( 0, 255, 173) # computer;computing;machine;device;data;processor;electronic;information;processing;system
76+
( 10, 0, 255) # swivel;chair
77+
(173, 255, 0) # boat
78+
( 0, 255, 153) # bar
79+
(255, 92, 0) # arcade;machine
80+
(255, 0, 255) # hovel;hut;hutch;shack;shanty
81+
(255, 0, 245) # bus;autobus;coach;charabanc;double-decker;jitney;motorbus;motorcoach;omnibus;passenger;vehicle
82+
(255, 0, 102) # towel
83+
(255, 173, 0) # light;source
84+
(255, 0, 20) # truck;motortruck
85+
(255, 184, 184) # tower
86+
( 0, 31, 255) # chandelier;pendant;pendent
87+
( 0, 255, 61) # awning;sunshade;sunblind
88+
( 0, 71, 255) # streetlight;street;lamp
89+
(255, 0, 204) # booth;cubicle;stall;kiosk
90+
( 0, 255, 194) # television;receiver;set;tv;box;boob;tube;telly;goggle
91+
( 0, 255, 82) # airplane;aeroplane;plane
92+
( 0, 10, 255) # dirt;track
93+
( 0, 112, 255) # apparel;wearing;dress;clothes
94+
( 51, 0, 255) # pole
95+
( 0, 194, 255) # land;ground;soil
96+
( 0, 122, 255) # bannister;banister;balustrade;balusters;handrail
97+
( 0, 255, 163) # escalator;moving;staircase;stairway
98+
(255, 153, 0) # ottoman;pouf;pouffe;puff;hassock
99+
( 0, 255, 10) # bottle
100+
(255, 112, 0) # buffet;counter;sideboard
101+
(143, 255, 0) # poster;posting;placard;notice;bill;card
102+
( 82, 0, 255) # stage
103+
(163, 255, 0) # van
104+
(255, 235, 0) # ship
105+
( 8, 184, 170) # fountain
106+
(133, 0, 255) # conveyer;belt;conveyor;transporter
107+
( 0, 255, 92) # canopy
108+
(184, 0, 255) # washer;automatic;washing;machine
109+
(255, 0, 31) # plaything;toy
110+
( 0, 184, 255) # swimming;pool;bath;natatorium
111+
( 0, 214, 255) # stool
112+
(255, 0, 112) # barrel;cask
113+
( 92, 255, 0) # basket;handbasket
114+
( 0, 224, 255) # waterfall;falls
115+
(112, 224, 255) # tent;collapsible;shelter
116+
( 70, 184, 160) # bag
117+
(163, 0, 255) # minibike;motorbike
118+
(153, 0, 255) # cradle
119+
( 71, 255, 0) # oven
120+
(255, 0, 163) # ball
121+
(255, 204, 0) # food;solid
122+
(255, 0, 143) # step;stair
123+
( 0, 255, 235) # tank;storage
124+
(133, 255, 0) # trade;name;brand;marque
125+
(255, 0, 235) # microwave;microwave;oven
126+
(245, 0, 255) # pot;flowerpot
127+
(255, 0, 122) # animal;animate;being;beast;brute;creature;fauna
128+
(255, 245, 0) # bicycle;bike;wheel;cycle
129+
( 10, 190, 212) # lake
130+
(214, 255, 0) # dishwasher;dish;washer;dishwashing;machine
131+
( 0, 204, 255) # screen;silver;projection
132+
( 20, 0, 255) # blanket;cover
133+
(255, 255, 0) # sculpture
134+
( 0, 153, 255) # hood;exhaust
135+
( 0, 41, 255) # sconce
136+
( 0, 255, 204) # vase
137+
( 41, 0, 255) # traffic;light;signal;stoplight
138+
( 41, 255, 0) # tray
139+
(173, 0, 255) # ashcan;trash;can;garbage;wastebin;ash;bin;ash-bin;ashbin;dustbin;barrel
140+
( 0, 245, 255) # fan
141+
( 71, 0, 255) # pier;wharf;wharfage;dock
142+
(122, 0, 255) # crt;screen
143+
( 0, 255, 184) # plate
144+
( 0, 92, 255) # monitor;monitoring;device
145+
(184, 255, 0) # bulletin;board;notice
146+
( 0, 133, 255) # shower
147+
(255, 214, 0) # radiator
148+
( 25, 194, 194) # glass;drinkin
149+
(102, 255, 0) # clock
150+
( 92, 0, 255) # flag

data/palettes/camvid_12cl_colors.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(128, 128, 128) # sky
2+
(128, 0, 0) # building
3+
(192, 192, 128) # pole
4+
(128, 64, 128) # road
5+
( 60, 40, 222) # pavement
6+
(128, 128, 0) # tree
7+
(192, 128, 128) # sign symbol
8+
( 64, 64, 128) # fence
9+
( 64, 0, 128) # car
10+
( 64, 64, 0) # pedestrian
11+
( 0, 128, 192) # bicyclist
12+
( 0, 0, 0) # unlabelled
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(128, 64, 128) # road
2+
(244, 35, 232) # sidewalk
3+
( 70, 70, 70) # building
4+
(102, 102, 156) # wall
5+
(190, 153, 153) # fence
6+
(153, 153, 153) # pole
7+
(250, 170, 30) # traffic light
8+
(220, 220, 0) # traffic sign
9+
(107, 142, 35) # vegetation
10+
(152, 251, 152) # terrain
11+
( 70, 130, 180) # sky
12+
(220, 20, 60) # person
13+
(255, 0, 0) # rider
14+
( 0, 0, 142) # car
15+
( 0, 0, 70) # truck
16+
( 0, 60, 100) # bus
17+
( 0, 80, 100) # train
18+
( 0, 0, 230) # motorcycle
19+
(119, 11, 32) # bicycle
20+
(255, 255, 255) # background
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
( 0, 0, 0) # background
2+
(128, 0, 0) # aeroplane
3+
( 0, 128, 0) # bicycle
4+
(128, 128, 0) # bird
5+
( 0, 0, 128) # boat
6+
(128, 0, 128) # bottle
7+
( 0, 128, 128) # bus
8+
(128, 128, 128) # car
9+
( 64, 0, 0) # cat
10+
(192, 0, 0) # chair
11+
( 64, 128, 0) # cow
12+
(192, 128, 0) # diningtable
13+
( 64, 0, 128) # dog
14+
(192, 0, 128) # horse
15+
( 64, 128, 128) # motorbike
16+
(192, 128, 128) # person
17+
( 0, 64, 0) # pottedplant
18+
(128, 64, 0) # sheep
19+
( 0, 192, 0) # sofa
20+
(128, 192, 0) # train
21+
( 0, 64, 128) # tvmonitor

demos/segmentation_demo/python/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This topic demonstrates how to run the Image Segmentation demo application, whic
88
99
## How It Works
1010

11-
Upon the start-up the demo application reads command line parameters and loads a network. The demo runs inference and shows results for each image captured from an input. Depending on number of inference requests processing simultaneously (-nireq parameter) the pipeline might minimize the time required to process each single image (for nireq 1) or maximize utilization of the device and overall processing performance.
11+
Upon the start-up the demo application reads command line parameters and loads a network. The demo runs inference and shows results for each image captured from an input. Demo provides default mapping of classes to colors and optionally, allow to specify mapping of classes to colors from simple text file, with using `--colors` argument. Depending on number of inference requests processing simultaneously (-nireq parameter) the pipeline might minimize the time required to process each single image (for nireq 1) or maximize utilization of the device and overall processing performance.
1212

1313
> **NOTE**: By default, Open Model Zoo demos expect input with BGR channels order. If you trained your model to work with RGB order, you need to manually rearrange the default channels order in the demo application or reconvert your model using the Model Optimizer tool with `--reverse_input_channels` argument specified. For more information about the argument, refer to **When to Reverse Input Channels** section of [Converting a Model Using General Conversion Parameters](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_Converting_Model_General.html).
1414
@@ -86,6 +86,14 @@ You can use the following command to do inference on CPU on images captured by a
8686
python3 segmentation_demo.py -i 0 -m <path_to_model>/semantic-segmentation-adas-0001.xml
8787
```
8888

89+
## Color palettes
90+
91+
The color palette is used to visualize predicted classes. By default, the colors from PASCAL VOC dataset are applied. In case then the number of output classes is larger than number of classes provided by PASCAL VOC dataset, the rest classes are randomly colorized.
92+
Also, one can use predefined colors from other datasets, like CAMVID.
93+
94+
Available colors files are in `<omz_dir>/data/palettes`.
95+
If you want to assign custom colors for classes, you should create a `.txt` file, where the each line contains colors in `(R, G, B)` format.
96+
8997
## Demo Output
9098

9199
The demo uses OpenCV to display the resulting images with blended segmentation mask.

demos/segmentation_demo/python/segmentation_demo.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ def __init__(self, colors_path=None):
7171

7272
def get_palette_from_file(self, colors_path):
7373
with open(colors_path, 'r') as file:
74-
return [eval(line.strip()) for line in file.readlines()]
74+
colors = []
75+
for line in file.readlines():
76+
values = line[line.index('(')+1:line.index(')')].split(',')
77+
colors.append([int(v.strip()) for v in values])
78+
return colors
7579

7680
def create_color_map(self):
77-
classes = np.array(self.color_palette, dtype=np.uint8)[:, ::-1] # BGR to RGB
81+
classes = np.array(self.color_palette, dtype=np.uint8)[:, ::-1] # RGB to BGR
7882
color_map = np.zeros((256, 1, 3), dtype=np.uint8)
7983
classes_num = len(classes)
8084
color_map[:classes_num, 0, :] = classes

0 commit comments

Comments
 (0)