Skip to content

Commit a32e189

Browse files
committed
Fix dataset appending when label count is available
1 parent a8d2568 commit a32e189

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

detectionmetrics/datasets/dataset.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,28 @@ def append(self, new_dataset: Self):
4444
:param new_dataset: Dataset to be appended
4545
:type new_dataset: Self
4646
"""
47-
assert self.ontology == new_dataset.ontology, "Ontologies don't match"
47+
if not self.has_label_count:
48+
assert self.ontology == new_dataset.ontology, "Ontologies don't match"
49+
else:
50+
# Check if classes match
51+
assert (
52+
self.ontology.keys() == new_dataset.ontology.keys()
53+
), "Ontologies don't match"
54+
for class_name in self.ontology:
55+
# Check if indices, and RGB values match
56+
assert (
57+
self.ontology[class_name]["idx"]
58+
== new_dataset.ontology[class_name]["idx"]
59+
), "Ontologies don't match"
60+
assert (
61+
self.ontology[class_name]["rgb"]
62+
== new_dataset.ontology[class_name]["rgb"]
63+
), "Ontologies don't match"
64+
65+
# Accumulate label count
66+
self.ontology[class_name]["label_count"] += new_dataset.ontology[
67+
class_name
68+
]["label_count"]
4869

4970
# Global filenames to avoid dealing with each dataset relative location
5071
self.make_fname_global()

0 commit comments

Comments
 (0)