Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

fix: Handle multi-layer image in YOLO export #244

Closed
wants to merge 1 commit into from
Closed
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
42 changes: 22 additions & 20 deletions label_studio_converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,26 +739,28 @@ def convert_to_yolo(
else self.iter_from_json_file(input_data)
)
for item_idx, item in enumerate(item_iterator):
# get image path and label file path
image_path = item['input'][data_key]
# download image
if not os.path.exists(image_path):
try:
image_path = download(
image_path,
output_image_dir,
project_dir=self.project_dir,
return_relative_path=True,
upload_dir=self.upload_dir,
download_resources=self.download_resources,
)
except:
logger.info(
'Unable to download {image_path}. The item {item} will be skipped'.format(
image_path=image_path, item=item
),
exc_info=True,
)
# get image path(s) and label file path
image_paths = item['input'][data_key]
image_paths = [image_paths] if isinstance(image_paths, str) else image_paths
# download image(s)
for image_path in reversed(image_paths):
if not os.path.exists(image_path):
try:
image_path = download(
image_path,
output_image_dir,
project_dir=self.project_dir,
return_relative_path=True,
upload_dir=self.upload_dir,
download_resources=self.download_resources,
)
except:
logger.info(
'Unable to download {image_path}. The item {item} will be skipped'.format(
image_path=image_path, item=item
),
exc_info=True,
)

# create dedicated subfolder for each labeler if split_labelers=True
labeler_subfolder = str(item['completed_by']) if split_labelers else ''
Expand Down