From fe5a07d9318d4e24822024bb70c20eb805eefea2 Mon Sep 17 00:00:00 2001 From: faycute Date: Fri, 30 Jul 2021 08:24:52 +0000 Subject: [PATCH 1/2] deal with 3.7 --- fastlabel/api.py | 6 +++++- fastlabel/converters.py | 3 ++- setup.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fastlabel/api.py b/fastlabel/api.py index fafca89..a592fe5 100644 --- a/fastlabel/api.py +++ b/fastlabel/api.py @@ -3,7 +3,11 @@ from .exceptions import FastLabelException, FastLabelInvalidException -FASTLABEL_ENDPOINT = "https://api.fastlabel.ai/v1/" +# FASTLABEL_ENDPOINT = "https://api.fastlabel.ai/v1/" + +# FASTLABEL_ENDPOINT = "http://localhost:4000/v1/" +FASTLABEL_ENDPOINT = "http://api:4000/v1/" +# export FASTLABEL_ACCESS_TOKEN=NTI3MmI4NTUtNWE1NC00ZWFiLWE4MDUtZDE5ZmQ0MjMzMjRi class Api: diff --git a/fastlabel/converters.py b/fastlabel/converters.py index e3ab609..51fd0dc 100644 --- a/fastlabel/converters.py +++ b/fastlabel/converters.py @@ -1,4 +1,5 @@ from concurrent.futures import ThreadPoolExecutor +from typing import List import copy import geojson @@ -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. """ diff --git a/setup.py b/setup.py index 8edd941..a0a4b13 100644 --- a/setup.py +++ b/setup.py @@ -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", From b0eb3473a8119a8ab3ffc2a5c84f71115465e57f Mon Sep 17 00:00:00 2001 From: faycute Date: Fri, 30 Jul 2021 08:26:12 +0000 Subject: [PATCH 2/2] fix --- fastlabel/__init__.py | 9 +++++---- fastlabel/api.py | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index a745640..bfc46f3 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1,6 +1,7 @@ import os import glob import json +from typing import List from logging import getLogger from PIL import Image, ImageDraw @@ -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. @@ -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. @@ -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) @@ -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. """ diff --git a/fastlabel/api.py b/fastlabel/api.py index a592fe5..fafca89 100644 --- a/fastlabel/api.py +++ b/fastlabel/api.py @@ -3,11 +3,7 @@ from .exceptions import FastLabelException, FastLabelInvalidException -# FASTLABEL_ENDPOINT = "https://api.fastlabel.ai/v1/" - -# FASTLABEL_ENDPOINT = "http://localhost:4000/v1/" -FASTLABEL_ENDPOINT = "http://api:4000/v1/" -# export FASTLABEL_ACCESS_TOKEN=NTI3MmI4NTUtNWE1NC00ZWFiLWE4MDUtZDE5ZmQ0MjMzMjRi +FASTLABEL_ENDPOINT = "https://api.fastlabel.ai/v1/" class Api: