Skip to content
Snippets Groups Projects
Commit 8a241052 authored by Chaza Abdelwahab's avatar Chaza Abdelwahab Committed by Yoann Schneider
Browse files

Only look for classes when we load them

parent 33f6dc16
No related branches found
No related tags found
1 merge request!44Only look for classes when we load them
Pipeline #74643 passed
......@@ -172,13 +172,16 @@ class HTRDataGenerator:
with_classes=self.should_filter_by_class,
with_metadata=self.should_filter_by_metadatas,
):
elem_classes = [c for c in elt["classes"] if c["state"] != "rejected"]
should_accept = True
if self.should_filter_by_class:
# at first filter to only have elements with accepted classes
# if accepted classes list is empty then should accept all
# except for ignored classes
elem_classes = [
c for c in elt["classes"] if c["state"] != "rejected"
]
should_accept = len(self.accepted_classes) == 0
for classification in elem_classes:
class_name = classification["ml_class"]["name"]
......@@ -193,6 +196,9 @@ class HTRDataGenerator:
continue
if self.should_filter_by_style:
elem_classes = [
c for c in elt["classes"] if c["state"] != "rejected"
]
style_counts = Counter()
for classification in elem_classes:
class_name = classification["ml_class"]["name"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment