Skip to content

Commit

Permalink
Implement feedback Philipp
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorSusmelj committed Dec 6, 2024
1 parent 560149c commit e36e21f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/labelformat/formats/yolov8.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,20 @@ def get_labels(self) -> Iterable[ImageObjectDetection]:
try:
with label_path.open() as file:
label_data = [line.strip().split() for line in file if line.strip()]
except Exception as e:
except (FileNotFoundError, PermissionError, IsADirectoryError) as e:
logger.error(
f"Error reading label file '{label_path}' for image '{image.filename}': {e}"
f"Failed to access label file '{label_path}' for image '{image.filename}': {e}"
)
continue # Skip processing this image due to access error
except (OSError, UnicodeDecodeError) as e:
logger.error(
f"Error reading contents of label file '{label_path}' for image '{image.filename}': {e}"
)
continue # Skip processing this image due to read error

objects = []
for entry in label_data:
if len(entry) < 5:
if len(entry) != 5:
logger.warning(
f"Invalid label format in file '{label_path}' for image '{image.filename}'. Skipping this annotation."
)
Expand Down

0 comments on commit e36e21f

Please sign in to comment.