55import json
66import logging
77import os
8+ from typing import Any , Sequence
9+
10+ from PIL import Image
811import requests
912from shapely import wkt
10- from typing import Any , Sequence
1113
1214from labelbox .exceptions import UnknownFormatError
1315from labelbox .exporters .pascal_voc_writer import Writer as PascalWriter
14- from PIL import Image
1516
1617
1718def from_json (labeled_data , annotations_output_dir , images_output_dir ,
@@ -61,7 +62,7 @@ def from_json(labeled_data, annotations_output_dir, images_output_dir,
6162 continue
6263
6364
64- def write_label (
65+ def write_label ( # pylint: disable-msg=too-many-arguments
6566 label_id : str , image_url : str , labels : Sequence [Any ], label_format : str ,
6667 images_output_dir : str , annotations_output_dir : str ):
6768 """Writes a single Pascal VOC formatted image and label pair to disk.
@@ -80,8 +81,9 @@ def write_label(
8081 response = requests .get (image_url , stream = True )
8182 response .raw .decode_content = True
8283 image = Image .open (response .raw )
83- image_name = ('{img_id}.{ext}' .format (img_id = label_id , ext = image .format .lower ()))
84- image_fqn = os .path .join (images_output_dir , image_name )
84+ image_fqn = os .path .join (
85+ images_output_dir ,
86+ '{img_id}.{ext}' .format (img_id = label_id , ext = image .format .lower ()))
8587 image .save (image_fqn , format = image .format )
8688
8789 # generate image annotation in Pascal VOC
0 commit comments