-
Notifications
You must be signed in to change notification settings - Fork 541
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
[BUG] Labels are swapped after exporting splits (test, train, val) in YOLOv5 format #1952
Comments
Hi @abaybektursun, your problem is that, when exporting in YOLOv5 format you must ensure that all splits use exactly the same classes list (YOLOv5 uses integer targets in the This is achieved in the example YOLOv5 export snippet from the FiftyOne docs by providing the same classes list via the # The splits to export
splits = ["train", "val"]
# All splits must use the same classes list
classes = ["list", "of", "classes"]
# The dataset or view to export
# We assume the dataset uses sample tags to encode the splits to export
dataset_or_view = fo.Dataset(...)
# Export the splits
for split in splits:
split_view = dataset_or_view.match_tags(split)
split_view.export(
export_dir=export_dir,
dataset_type=fo.types.YOLOv5Dataset,
label_field=label_field,
split=split,
classes=classes,
) You can use distinct() to conveniently retrieve a sorted list of all observed labels in a given field, eg: classes = dataset.distinct("ground_truth.detections.label") |
I do think we should update the YOLOv5 exporter to raise an error when different class lists are encountered when exporting multiple splits into the same directory. That should never be allowed because it will lead to the label mismatch observed here. Without providing the |
@abaybektursun providing classes to export worked for me as work around in this case |
System information
fiftyone --version
): FiftyOne v0.16.5, Voxel51, Inc.Commands to reproduce
'train'
the class labels are swappedDescribe the problem
I have a task for object detection with 2 classes. After training a Yolo model I noticed that my confusion matrix looks weird, it was performing poorly on the same classes but well on the opposite classes, meaning in my validation set labels were swapped. After hours of debugging I pinned it down. Fiftyone has a bug. When you split a dataset and then export it into YOLOv5 format, it messes up the labels (swaps them) for train set.
Code to reproduce issue
Described in the
Commands to reproduce
section in detail.Other info / logs
My dataset has 2 classes.
What areas of FiftyOne does this bug affect?
App
: FiftyOne application issueCore
: Corefiftyone
Python library issueServer
: Fiftyone server issueWillingness to contribute
The FiftyOne Community encourages bug fix contributions. Would you or another
member of your organization be willing to contribute a fix for this bug to the
FiftyOne codebase?
from the FiftyOne community.
The text was updated successfully, but these errors were encountered: