Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions fastlabel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import glob
import json
from typing import List
from logging import getLogger
from PIL import Image, ImageDraw

Expand Down Expand Up @@ -615,7 +616,7 @@ def export_labelme(self, tasks: list, output_dir: str = os.path.join("output", "


# Instance / Semantic Segmetation
def export_instance_segmentation(self, tasks: list, output_dir: str = os.path.join("output", "instance_segmentation"), pallete: list[int] = const.COLOR_PALETTE) -> None:
def export_instance_segmentation(self, tasks: list, output_dir: str = os.path.join("output", "instance_segmentation"), pallete: List[int] = const.COLOR_PALETTE) -> None:
"""
Convert tasks to index color instance segmentation (PNG files).
Supports only bbox, polygon and segmentation annotation types. Hollowed points are not supported.
Expand All @@ -629,7 +630,7 @@ def export_instance_segmentation(self, tasks: list, output_dir: str = os.path.jo
for task in tasks:
self.__export_index_color_image(task=task, output_dir=output_dir, pallete=pallete, is_instance_segmentation=True)

def export_semantic_segmentation(self, tasks: list, output_dir: str = os.path.join("output", "semantic_segmentation"), pallete: list[int] = const.COLOR_PALETTE) -> None:
def export_semantic_segmentation(self, tasks: list, output_dir: str = os.path.join("output", "semantic_segmentation"), pallete: List[int] = const.COLOR_PALETTE) -> None:
"""
Convert tasks to index color semantic segmentation (PNG files).
Supports only bbox, polygon and segmentation annotation types. Hollowed points are not supported.
Expand All @@ -650,7 +651,7 @@ def export_semantic_segmentation(self, tasks: list, output_dir: str = os.path.jo
for task in tasks:
self.__export_index_color_image(task=task, output_dir=output_dir, pallete=pallete, is_instance_segmentation=False, classes=classes)

def __export_index_color_image(self, task: list, output_dir: str, pallete: list[int], is_instance_segmentation: bool = True, classes: list = []) -> None:
def __export_index_color_image(self, task: list, output_dir: str, pallete: List[int], is_instance_segmentation: bool = True, classes: list = []) -> None:
image = Image.new("RGB", (task["width"], task["height"]), 0)
image = image.convert('P')
image.putpalette(pallete)
Expand Down Expand Up @@ -680,7 +681,7 @@ def __export_index_color_image(self, task: list, output_dir: str, pallete: list[
os.makedirs(os.path.dirname(image_path), exist_ok=True)
image.save(image_path)

def __get_pillow_draw_points(self, points: list[int]) -> list[int]:
def __get_pillow_draw_points(self, points: List[int]) -> List[int]:
"""
Convert points to pillow draw points. Diagonal points are not supported.
"""
Expand Down
3 changes: 2 additions & 1 deletion fastlabel/converters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from concurrent.futures import ThreadPoolExecutor
from typing import List

import copy
import geojson
Expand Down Expand Up @@ -302,7 +303,7 @@ def to_pixel_coordinates(tasks: list) -> list:
continue
return tasks

def __get_pixel_coordinates(points: list[int or float]) -> list[int]:
def __get_pixel_coordinates(points: List[int or float]) -> List[int]:
"""
Remove diagonal coordinates and return pixel outline coordinates.
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="fastlabel",
version="0.9.7",
version="0.9.8",
author="eisuke-ueta",
author_email="eisuke.ueta@fastlabel.ai",
description="The official Python SDK for FastLabel API, the Data Platform for AI",
Expand Down