@@ -78,31 +78,33 @@ def stop(self):
7878 self .stopped = True
7979
8080
81- STANDARD_COLORS = [
82- 'AliceBlue' , 'Chartreuse' , 'Aqua' , 'Aquamarine' , 'Azure' , 'Beige' , 'Bisque' ,
83- 'BlanchedAlmond' , 'BlueViolet' , 'BurlyWood' , 'CadetBlue' , 'AntiqueWhite' ,
84- 'Chocolate' , 'Coral' , 'CornflowerBlue' , 'Cornsilk' , 'Crimson' , 'Cyan' ,
85- 'DarkCyan' , 'DarkGoldenRod' , 'DarkGrey' , 'DarkKhaki' , 'DarkOrange' ,
86- 'DarkOrchid' , 'DarkSalmon' , 'DarkSeaGreen' , 'DarkTurquoise' , 'DarkViolet' ,
87- 'DeepPink' , 'DeepSkyBlue' , 'DodgerBlue' , 'FireBrick' , 'FloralWhite' ,
88- 'ForestGreen' , 'Fuchsia' , 'Gainsboro' , 'GhostWhite' , 'Gold' , 'GoldenRod' ,
89- 'Salmon' , 'Tan' , 'HoneyDew' , 'HotPink' , 'IndianRed' , 'Ivory' , 'Khaki' ,
90- 'Lavender' , 'LavenderBlush' , 'LawnGreen' , 'LemonChiffon' , 'LightBlue' ,
91- 'LightCoral' , 'LightCyan' , 'LightGoldenRodYellow' , 'LightGray' , 'LightGrey' ,
92- 'LightGreen' , 'LightPink' , 'LightSalmon' , 'LightSeaGreen' , 'LightSkyBlue' ,
93- 'LightSlateGray' , 'LightSlateGrey' , 'LightSteelBlue' , 'LightYellow' , 'Lime' ,
94- 'LimeGreen' , 'Linen' , 'Magenta' , 'MediumAquaMarine' , 'MediumOrchid' ,
95- 'MediumPurple' , 'MediumSeaGreen' , 'MediumSlateBlue' , 'MediumSpringGreen' ,
96- 'MediumTurquoise' , 'MediumVioletRed' , 'MintCream' , 'MistyRose' , 'Moccasin' ,
97- 'NavajoWhite' , 'OldLace' , 'Olive' , 'OliveDrab' , 'Orange' , 'OrangeRed' ,
98- 'Orchid' , 'PaleGoldenRod' , 'PaleGreen' , 'PaleTurquoise' , 'PaleVioletRed' ,
99- 'PapayaWhip' , 'PeachPuff' , 'Peru' , 'Pink' , 'Plum' , 'PowderBlue' , 'Purple' ,
100- 'Red' , 'RosyBrown' , 'RoyalBlue' , 'SaddleBrown' , 'Green' , 'SandyBrown' ,
101- 'SeaGreen' , 'SeaShell' , 'Sienna' , 'Silver' , 'SkyBlue' , 'SlateBlue' ,
102- 'SlateGray' , 'SlateGrey' , 'Snow' , 'SpringGreen' , 'SteelBlue' , 'GreenYellow' ,
103- 'Teal' , 'Thistle' , 'Tomato' , 'Turquoise' , 'Violet' , 'Wheat' , 'White' ,
104- 'WhiteSmoke' , 'Yellow' , 'YellowGreen'
105- ]
81+ def standard_colors ():
82+ colors = [
83+ 'AliceBlue' , 'Chartreuse' , 'Aqua' , 'Aquamarine' , 'Azure' , 'Beige' , 'Bisque' ,
84+ 'BlanchedAlmond' , 'BlueViolet' , 'BurlyWood' , 'CadetBlue' , 'AntiqueWhite' ,
85+ 'Chocolate' , 'Coral' , 'CornflowerBlue' , 'Cornsilk' , 'Crimson' , 'Cyan' ,
86+ 'DarkCyan' , 'DarkGoldenRod' , 'DarkGrey' , 'DarkKhaki' , 'DarkOrange' ,
87+ 'DarkOrchid' , 'DarkSalmon' , 'DarkSeaGreen' , 'DarkTurquoise' , 'DarkViolet' ,
88+ 'DeepPink' , 'DeepSkyBlue' , 'DodgerBlue' , 'FireBrick' , 'FloralWhite' ,
89+ 'ForestGreen' , 'Fuchsia' , 'Gainsboro' , 'GhostWhite' , 'Gold' , 'GoldenRod' ,
90+ 'Salmon' , 'Tan' , 'HoneyDew' , 'HotPink' , 'IndianRed' , 'Ivory' , 'Khaki' ,
91+ 'Lavender' , 'LavenderBlush' , 'LawnGreen' , 'LemonChiffon' , 'LightBlue' ,
92+ 'LightCoral' , 'LightCyan' , 'LightGoldenRodYellow' , 'LightGray' , 'LightGrey' ,
93+ 'LightGreen' , 'LightPink' , 'LightSalmon' , 'LightSeaGreen' , 'LightSkyBlue' ,
94+ 'LightSlateGray' , 'LightSlateGrey' , 'LightSteelBlue' , 'LightYellow' , 'Lime' ,
95+ 'LimeGreen' , 'Linen' , 'Magenta' , 'MediumAquaMarine' , 'MediumOrchid' ,
96+ 'MediumPurple' , 'MediumSeaGreen' , 'MediumSlateBlue' , 'MediumSpringGreen' ,
97+ 'MediumTurquoise' , 'MediumVioletRed' , 'MintCream' , 'MistyRose' , 'Moccasin' ,
98+ 'NavajoWhite' , 'OldLace' , 'Olive' , 'OliveDrab' , 'Orange' , 'OrangeRed' ,
99+ 'Orchid' , 'PaleGoldenRod' , 'PaleGreen' , 'PaleTurquoise' , 'PaleVioletRed' ,
100+ 'PapayaWhip' , 'PeachPuff' , 'Peru' , 'Pink' , 'Plum' , 'PowderBlue' , 'Purple' ,
101+ 'Red' , 'RosyBrown' , 'RoyalBlue' , 'SaddleBrown' , 'Green' , 'SandyBrown' ,
102+ 'SeaGreen' , 'SeaShell' , 'Sienna' , 'Silver' , 'SkyBlue' , 'SlateBlue' ,
103+ 'SlateGray' , 'SlateGrey' , 'Snow' , 'SpringGreen' , 'SteelBlue' , 'GreenYellow' ,
104+ 'Teal' , 'Thistle' , 'Tomato' , 'Turquoise' , 'Violet' , 'Wheat' , 'White' ,
105+ 'WhiteSmoke' , 'Yellow' , 'YellowGreen'
106+ ]
107+ return colors
106108
107109
108110def color_name_to_rgb ():
@@ -122,7 +124,7 @@ def draw_boxes_and_labels(
122124 max_boxes_to_draw = 20 ,
123125 min_score_thresh = .5 ,
124126 agnostic_mode = False ):
125- """Returns boxes coordinates of the boxes , class names and colors
127+ """Returns boxes coordinates, class names and colors
126128
127129 Args:
128130 boxes: a numpy array of shape [N, 4]
@@ -175,8 +177,8 @@ def draw_boxes_and_labels(
175177 if agnostic_mode :
176178 box_to_color_map [box ] = 'DarkOrange'
177179 else :
178- box_to_color_map [box ] = STANDARD_COLORS [
179- classes [i ] % len (STANDARD_COLORS )]
180+ box_to_color_map [box ] = standard_colors () [
181+ classes [i ] % len (standard_colors () )]
180182
181183 # Store all the coordinates of the boxes, class names and colors
182184 color_rgb = color_name_to_rgb ()
@@ -185,7 +187,7 @@ def draw_boxes_and_labels(
185187 class_colors = []
186188 for box , color in six .iteritems (box_to_color_map ):
187189 ymin , xmin , ymax , xmax = box
188- rect_points .append ((ymin , xmin , ymax , xmax ))
190+ rect_points .append (dict (ymin = ymin , xmin = xmin , ymax = ymax , xmax = xmax ))
189191 class_names .append (box_to_display_str_map [box ])
190192 class_colors .append (color_rgb [color .lower ()])
191193 return rect_points , class_names , class_colors
0 commit comments