22import json
33import os
44import re
5- from logging import getLogger
5+ import logging
66from typing import List
77from concurrent .futures import ThreadPoolExecutor
88import cv2
1111from PIL import Image , ImageColor , ImageDraw
1212from fastlabel import const , converters , utils
1313from fastlabel .const import (
14+ EXPORT_IMAGE_WITH_ANNOTATIONS_SUPPORTED_IMAGE_TYPES ,
1415 KEYPOINT_MIN_STROKE_WIDTH ,
1516 OPACITY_DARK ,
1617 OPACITY_THIN ,
2223from .api import Api
2324from .exceptions import FastLabelInvalidException
2425
25- logger = getLogger (__name__ )
26+ logger = logging .getLogger (__name__ )
27+ logging .basicConfig (
28+ level = logging .INFO ,
29+ format = "%(levelname)s: %(message)s" ,
30+ )
2631
2732
2833class Client :
@@ -2263,7 +2268,7 @@ def __create_image_with_annotation(self, img_file_path_task):
22632268 try :
22642269 rgb = ImageColor .getcolor (task_annotation ["color" ], "RGB" )
22652270 except Exception as e :
2266- print (e )
2271+ logger . info (e )
22672272 if not rgb :
22682273 continue
22692274 rgba_dark = rgb + (OPACITY_DARK ,)
@@ -2379,7 +2384,7 @@ def __create_image_with_annotation(self, img_file_path_task):
23792384 task_annotation_keypoint_keypoint_color , "RGB"
23802385 )
23812386 except Exception as e :
2382- print (
2387+ logger . info (
23832388 f"Invalid color: { task_annotation_keypoint_keypoint_color } , "
23842389 f"content_name: { task_annotation_keypoint_name } , { e } "
23852390 )
@@ -2476,8 +2481,8 @@ def export_image_with_annotations(
24762481 for target_file_candidate_path in target_file_candidate_paths :
24772482 if not os .path .isfile (target_file_candidate_path ):
24782483 continue
2479- if not target_file_candidate_path .endswith (
2480- ( ".jpeg" , ".jpg" , ".png" , ".JPEG" , ".JPG" , ".PNG" , ".tif" , ".TIF" )
2484+ if not target_file_candidate_path .lower (). endswith (
2485+ EXPORT_IMAGE_WITH_ANNOTATIONS_SUPPORTED_IMAGE_TYPES
24812486 ):
24822487 continue
24832488 img_file_paths .append (target_file_candidate_path )
@@ -2496,7 +2501,7 @@ def export_image_with_annotations(
24962501 None ,
24972502 )
24982503 if not task :
2499- print (f"not find task. filepath: { task_name } " )
2504+ logger . info (f"Not find task. filepath: { task_name } " )
25002505 continue
25012506 img_file_path_task_list .append ([img_file_path , task , output_dir ])
25022507
0 commit comments