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

Commit

Permalink
warns user to declare out_type predictions if intending to import YOL…
Browse files Browse the repository at this point in the history
…O prediction scores
  • Loading branch information
carbaro committed Jun 5, 2024
1 parent 4e76ff5 commit a58ef2b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion label_studio_converter/imports/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def convert_yolo_to_ls(
logger.info(f'image extensions->, {image_ext}')

# loop through images
contains_predictions = False
for f in os.listdir(images_dir):
image_file_found_flag = False
for ext in image_ext:
Expand Down Expand Up @@ -113,7 +114,8 @@ def convert_yolo_to_ls(
for line in lines:
values = line.split()
label_id, x, y, width, height = values[0:5]
score = float(values[5]) if len(values) >= 6 else None
contains_predictions = (len(values) >= 6) or contains_predictions
score = float(values[5]) if contains_predictions else None
x, y, width, height = (
float(x),
float(y),
Expand Down Expand Up @@ -167,6 +169,12 @@ def convert_yolo_to_ls(
f' {help_root_dir}\n'
f' 4. Import "{out_file}" to the project\n'
)
if contains_predictions and (out_type != 'predictions'):
logger.warn(
f' WARNING:\n'
f' Annotations with prediction confidence scores detected in your data would be imported as confirmed annotations.\n'
f' If you intended to import these as predictions, please specify so with the option --out_type=\'predictions\'\n'
)
else:
logger.error('No labels converted')

Expand Down

0 comments on commit a58ef2b

Please sign in to comment.