Skip to content
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

Loader color_space attribute #226

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions luxonis_ml/data/loaders/luxonis_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
height: Optional[int] = None,
width: Optional[int] = None,
keep_aspect_ratio: bool = True,
out_image_format: Literal["RGB", "BGR"] = "RGB",
color_space: Literal["RGB", "BGR"] = "RGB",
*,
update_mode: UpdateMode = UpdateMode.ALWAYS,
) -> None:
Expand Down Expand Up @@ -88,8 +88,8 @@ def __init__(
@type keep_aspect_ratio: bool
@param keep_aspect_ratio: Whether to keep the aspect ratio of the
images. Defaults to C{True}.
@type out_image_format: Literal["RGB", "BGR"]
@param out_image_format: The format of the output images. Defaults
@type color_space: Literal["RGB", "BGR"]
@param color_space: The color space of the output images. Defaults
to C{"RGB"}.
@type update_mode: UpdateMode
@param update_mode: Enum that determines the sync mode:
Expand All @@ -98,7 +98,7 @@ def __init__(
"""

self.logger = logging.getLogger(__name__)
self.out_image_format = out_image_format
self.color_space = color_space

self.dataset = dataset
self.sync_mode = self.dataset.is_remote
Expand Down Expand Up @@ -212,7 +212,7 @@ def __getitem__(self, idx: int) -> LoaderOutput:
else:
img, labels = self._load_with_augmentations(idx)

if self.out_image_format == "BGR":
if self.color_space == "BGR":
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)

return img, labels
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/test_dataset_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_parking_lot_generate(
augmentation_config=augmentation_config,
height=height,
width=width,
out_image_format="BGR",
color_space="BGR",
keep_aspect_ratio=True,
)
for _, labels in loader:
Expand Down
Loading