@@ -355,9 +355,12 @@ def visualize_results(
355355 )
356356
357357 if fill_mask :
358- color_mask = np .zeros_like (img )
359- color_mask [mask_resized > 0 ] = color
360- labeled_image = cv2 .addWeighted (labeled_image , 1 , color_mask , alpha , 0 )
358+ if alpha == 1 :
359+ cv2 .fillPoly (labeled_image , pts = mask_contours , color = color )
360+ else :
361+ color_mask = np .zeros_like (img )
362+ color_mask [mask_resized > 0 ] = color
363+ labeled_image = cv2 .addWeighted (labeled_image , 1 , color_mask , alpha , 0 )
361364
362365 cv2 .drawContours (labeled_image , mask_contours , - 1 , color , thickness )
363366
@@ -366,7 +369,7 @@ def visualize_results(
366369 points = np .array (polygons [i ].reshape ((- 1 , 1 , 2 )), dtype = np .int32 )
367370 cv2 .drawContours (labeled_image , [points ], - 1 , color , thickness )
368371 if fill_mask :
369- cv2 .fillPoly (labeled_image , pts = [points ], color = ( * color , alpha ) )
372+ cv2 .fillPoly (labeled_image , pts = [points ], color = color )
370373
371374 # Write class label
372375 if show_boxes :
0 commit comments