Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update YOLOv5DatasetImporter to support loading list of .txt #4742

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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
30 changes: 15 additions & 15 deletions fiftyone/utils/yolo.py
brimoor marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -506,25 +506,25 @@ def setup(self):
)

dataset_path = d.get("path", "")
data = fos.normpath(os.path.join(dataset_path, d[self.split]))
split_info = d[self.split]
if isinstance(split_info, str):
split_info = [split_info]
data = [
fos.normpath(os.path.join(dataset_path, si)) for si in split_info
]
classes = _parse_yolo_classes(d.get("names", None))

if etau.is_str(data) and data.endswith(".txt"):
txt_path = _parse_yolo_v5_path(data, self.yaml_path)
image_paths = [
_parse_yolo_v5_path(fos.normpath(p), txt_path)
for p in _read_file_lines(txt_path)
]
else:
if etau.is_str(data):
data_dirs = [data]
image_paths = []
for data_path in data:
if etau.is_str(data_path) and data_path.endswith(".txt"):
txt_path = _parse_yolo_v5_path(data_path, self.yaml_path)
image_paths.extend(
_parse_yolo_v5_path(fos.normpath(p), txt_path)
for p in _read_file_lines(txt_path)
)
brimoor marked this conversation as resolved.
Show resolved Hide resolved
else:
data_dirs = data

image_paths = []
for data_dir in data_dirs:
data_dir = fos.normpath(
_parse_yolo_v5_path(data_dir, self.yaml_path)
_parse_yolo_v5_path(data_path, self.yaml_path)
)
image_paths.extend(
etau.list_files(data_dir, abs_paths=True, recursive=True)
Expand Down
Loading