Skip to content

Commit d2b9af4

Browse files
authored
Yolov8 parse roboflow datasets (#28)
* Add new test cases for handling wrong paths * Add support for handling wrong paths from roboflow. * Implement support for intentional ../ paths * Restructure tests * Adding types * Revert custom types * Cleanu types for tests * Add underscore to test classes
1 parent b1b7c42 commit d2b9af4

File tree

2 files changed

+268
-158
lines changed

2 files changed

+268
-158
lines changed

src/labelformat/formats/yolov8.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,19 @@ def _root_dir(self) -> Path:
6969
return self._config_file.parent
7070

7171
def _images_dir(self) -> Path:
72+
"""Get images directory from YOLOv8 config file with fallback logic."""
7273
root_dir = self._root_dir()
73-
return root_dir / str(self._config_data[self._split])
74+
split_path = str(self._config_data[self._split])
75+
# Try original path first, then fallback to modified path for Roboflow-style configs
76+
path = root_dir / split_path
77+
if (
78+
not path.exists()
79+
and "path" not in self._config_data
80+
and split_path.startswith("../")
81+
):
82+
split_path = split_path.replace("../", "./", 1)
83+
path = root_dir / split_path
84+
return path
7485

7586
def _labels_dir(self) -> Path:
7687
"""Get labels directory from YOLOv8 config file.

0 commit comments

Comments
 (0)