Skip to content

Commit 6f24e9c

Browse files
committed
skip_clean no longer needs to be passed explicitly to parsers
1 parent 504b557 commit 6f24e9c

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

luxonis_ml/data/parsers/base_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def parse_split(
151151
@rtype: LuxonisDataset
152152
@return: C{LDF} with all the images and annotations parsed.
153153
"""
154+
self.skip_clean = kwargs.pop("skip_clean", False)
154155
added_images = self._parse_split(**kwargs)
155156
if split is not None:
156157
self.dataset.make_splits({split: added_images})
@@ -169,6 +170,7 @@ def parse_dir(self, dataset_dir: Path, **kwargs) -> BaseDataset:
169170
@rtype: LuxonisDataset
170171
@return: C{LDF} with all the images and annotations parsed.
171172
"""
173+
self.skip_clean = kwargs.pop("skip_clean", False)
172174
train, val, test = self.from_dir(dataset_dir, **kwargs)
173175

174176
self.dataset.make_splits({"train": train, "val": val, "test": test})

luxonis_ml/data/parsers/coco_parser.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def from_dir(
127127
use_keypoint_ann: bool = False,
128128
keypoint_ann_paths: dict[str, str] | None = None,
129129
split_val_to_test: bool = True,
130-
skip_clean: bool = False,
131130
) -> tuple[list[Path], list[Path], list[Path]]:
132131
dir_format, splits = COCOParser._detect_dataset_dir_format(dataset_dir)
133132
if dir_format is None:
@@ -162,7 +161,9 @@ def from_dir(
162161
else train_paths["annotation_path"]
163162
)
164163
cleaned_annotation_path = (
165-
train_ann_path if skip_clean else clean_annotations(train_ann_path)
164+
train_ann_path
165+
if self.skip_clean
166+
else clean_annotations(train_ann_path)
166167
)
167168
added_train_imgs = self._parse_split(
168169
image_dir=train_paths["image_dir"],
@@ -235,7 +236,6 @@ def from_split(
235236
self,
236237
image_dir: Path,
237238
annotation_path: Path,
238-
skip_clean: bool = False,
239239
) -> ParserOutput:
240240
"""Parses annotations from COCO format to LDF. Annotations
241241
include classification, segmentation, object detection and
@@ -245,16 +245,13 @@ def from_split(
245245
@param image_dir: Path to directory with images
246246
@type annotation_path: Path
247247
@param annotation_path: Path to annotation json file
248-
@type skip_clean: bool
249-
@param skip_clean: If C{True}, skip automatic cleaning of known
250-
dataset issues. Defaults to C{False}.
251248
@rtype: L{ParserOutput}
252249
@return: Annotation generator, list of classes names, skeleton
253250
dictionary for keypoints and list of added images.
254251
"""
255252
annotation_path = (
256253
annotation_path
257-
if skip_clean
254+
if self.skip_clean
258255
else clean_annotations(annotation_path)
259256
)
260257

luxonis_ml/data/parsers/fiftyone_classification_parser.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ def _extract_native_classes(labels_path: Path) -> dict[int, str]:
114114
classes = labels_data.get("classes", [])
115115
return dict(enumerate(classes))
116116

117-
def from_split(
118-
self, split_path: Path, skip_clean: bool = False
119-
) -> ParserOutput:
117+
def from_split(self, split_path: Path) -> ParserOutput:
120118
labels_path = split_path / "labels.json"
121119
data_path = split_path / "data"
122120

@@ -125,7 +123,7 @@ def from_split(
125123
# and label indices, and set native classes
126124
is_flat_structure = split_path.name not in self.SPLIT_NAMES
127125
if is_flat_structure:
128-
if not skip_clean:
126+
if not self.skip_clean:
129127
labels_path = clean_imagenet_annotations(labels_path)
130128
native_classes = self._extract_native_classes(labels_path)
131129
if native_classes:

0 commit comments

Comments
 (0)