11import os
22import glob
33import json
4+ from typing import List
45from logging import getLogger
56from PIL import Image , ImageDraw
67
@@ -615,7 +616,7 @@ def export_labelme(self, tasks: list, output_dir: str = os.path.join("output", "
615616
616617
617618 # Instance / Semantic Segmetation
618- def export_instance_segmentation (self , tasks : list , output_dir : str = os .path .join ("output" , "instance_segmentation" ), pallete : list [int ] = const .COLOR_PALETTE ) -> None :
619+ def export_instance_segmentation (self , tasks : list , output_dir : str = os .path .join ("output" , "instance_segmentation" ), pallete : List [int ] = const .COLOR_PALETTE ) -> None :
619620 """
620621 Convert tasks to index color instance segmentation (PNG files).
621622 Supports only bbox, polygon and segmentation annotation types. Hollowed points are not supported.
@@ -629,7 +630,7 @@ def export_instance_segmentation(self, tasks: list, output_dir: str = os.path.jo
629630 for task in tasks :
630631 self .__export_index_color_image (task = task , output_dir = output_dir , pallete = pallete , is_instance_segmentation = True )
631632
632- def export_semantic_segmentation (self , tasks : list , output_dir : str = os .path .join ("output" , "semantic_segmentation" ), pallete : list [int ] = const .COLOR_PALETTE ) -> None :
633+ def export_semantic_segmentation (self , tasks : list , output_dir : str = os .path .join ("output" , "semantic_segmentation" ), pallete : List [int ] = const .COLOR_PALETTE ) -> None :
633634 """
634635 Convert tasks to index color semantic segmentation (PNG files).
635636 Supports only bbox, polygon and segmentation annotation types. Hollowed points are not supported.
@@ -650,7 +651,7 @@ def export_semantic_segmentation(self, tasks: list, output_dir: str = os.path.jo
650651 for task in tasks :
651652 self .__export_index_color_image (task = task , output_dir = output_dir , pallete = pallete , is_instance_segmentation = False , classes = classes )
652653
653- def __export_index_color_image (self , task : list , output_dir : str , pallete : list [int ], is_instance_segmentation : bool = True , classes : list = []) -> None :
654+ def __export_index_color_image (self , task : list , output_dir : str , pallete : List [int ], is_instance_segmentation : bool = True , classes : list = []) -> None :
654655 image = Image .new ("RGB" , (task ["width" ], task ["height" ]), 0 )
655656 image = image .convert ('P' )
656657 image .putpalette (pallete )
@@ -680,7 +681,7 @@ def __export_index_color_image(self, task: list, output_dir: str, pallete: list[
680681 os .makedirs (os .path .dirname (image_path ), exist_ok = True )
681682 image .save (image_path )
682683
683- def __get_pillow_draw_points (self , points : list [int ]) -> list [int ]:
684+ def __get_pillow_draw_points (self , points : List [int ]) -> List [int ]:
684685 """
685686 Convert points to pillow draw points. Diagonal points are not supported.
686687 """
0 commit comments