@@ -96,14 +96,32 @@ def test_draw_boxes(self):
96
96
expected = torch .as_tensor (np .array (Image .open (path ))).permute (2 , 0 , 1 )
97
97
self .assertTrue (torch .equal (result , expected ))
98
98
99
- def test_draw_segmentation_masks (self ):
99
+ def test_draw_segmentation_masks_colors (self ):
100
100
img = torch .full ((3 , 20 , 20 ), 255 , dtype = torch .uint8 )
101
101
colors = ["green" , "#FF00FF" , (0 , 255 , 0 ), "red" ]
102
- labels = ["a" , "b" , "c" , "d" ]
103
- boxes = torch .tensor ([[1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 15 , 16 , 17 , 18 , 19 , 20 ]])
104
- result = utils .draw_segmentation_masks (img , boxes , labels = labels , colors = colors )
102
+ # TODO
103
+ masks = torch .tensor ([1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ])
104
+ result = utils .draw_segmentation_masks (img , masks , colors = colors )
105
+
106
+ path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "assets" ,
107
+ "fakedata" , "draw_segm_masks_colors_util.png" )
108
+
109
+ if not os .path .exists (path ):
110
+ res = Image .fromarray (result .permute (1 , 2 , 0 ).contiguous ().numpy ())
111
+ res .save (path )
112
+
113
+ expected = torch .as_tensor (np .array (Image .open (path ))).permute (2 , 0 , 1 )
114
+ self .assertTrue (torch .equal (result , expected ))
115
+
116
+ def test_draw_segmentation_masks_no_colors (self ):
117
+ img = torch .full ((3 , 20 , 20 ), 255 , dtype = torch .uint8 )
118
+ # TODO
119
+ masks = torch .tensor ([1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ])
120
+ result = utils .draw_segmentation_masks (img , masks , colors = None )
121
+
122
+ path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "assets" ,
123
+ "fakedata" , "draw_segm_masks_no_colors_util.png" )
105
124
106
- path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "assets" , "fakedata" , "draw_segm_masks_util.png" )
107
125
if not os .path .exists (path ):
108
126
res = Image .fromarray (result .permute (1 , 2 , 0 ).contiguous ().numpy ())
109
127
res .save (path )
0 commit comments