Skip to content

Commit 6983d85

Browse files
committed
add unfound Flip back to skipped augmentations to keypoints
1 parent b1cbece commit 6983d85

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

luxonis_ml/data/augmentations/albumentations_engine.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,33 @@ def apply_to_array(
241241
...
242242
"""
243243

244+
def _should_skip_augmentation(
245+
self, config_item: dict[str, Any], available_target_types: set
246+
) -> bool:
247+
skip_rules = {
248+
"keypoints": ["Flip"],
249+
}
250+
augmentation_name = config_item["name"]
251+
skipped_for = [
252+
target_type
253+
for target_type, skip_list in skip_rules.items()
254+
if target_type in available_target_types
255+
and augmentation_name in skip_list
256+
]
257+
if skipped_for:
258+
extra_msg = ""
259+
if "keypoints" in skipped_for and augmentation_name in [
260+
"HorizontalFlip",
261+
"VerticalFlip",
262+
"Flip",
263+
]:
264+
extra_msg = " For keypoints, please use 'HorizontalSymetricKeypointsFlip' or 'VerticalSymetricKeypointsFlip'."
265+
logger.warning(
266+
f"Skipping augmentation '{augmentation_name}' due to known issues for {skipped_for} target types. {extra_msg}"
267+
)
268+
return True
269+
return False
270+
244271
@override
245272
def __init__(
246273
self,
@@ -338,6 +365,16 @@ def __init__(
338365
if is_validation_pipeline:
339366
config = (a for a in config if a["name"] == "Normalize")
340367

368+
available_target_types = set(self.targets.values())
369+
370+
for config_item in config:
371+
if self._should_skip_augmentation(
372+
config_item, available_target_types
373+
):
374+
continue
375+
376+
cfg = AlbumentationConfigItem(**config_item) # type: ignore
377+
341378
for config_item in config:
342379
cfg = AlbumentationConfigItem(**config_item) # type: ignore
343380

0 commit comments

Comments
 (0)