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

Updated ChannelDropout #2240

Merged
merged 1 commit into from
Jan 7, 2025
Merged
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
17 changes: 1 addition & 16 deletions albumentations/augmentations/dropout/channel_dropout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

from collections.abc import Mapping
from typing import Annotated, Any
from warnings import warn

import numpy as np
from albucore import get_num_channels
from pydantic import AfterValidator, model_validator
from typing_extensions import Self
from pydantic import AfterValidator

from albumentations.core.pydantic import check_range_bounds
from albumentations.core.transforms_interface import BaseTransformInitSchema, ImageOnlyTransform
Expand Down Expand Up @@ -76,24 +74,11 @@ class ChannelDropout(ImageOnlyTransform):

class InitSchema(BaseTransformInitSchema):
channel_drop_range: Annotated[tuple[int, int], AfterValidator(check_range_bounds(1, None))]
fill_value: float | None
fill: float

@model_validator(mode="after")
def validate_fill(self) -> Self:
if self.fill_value is not None:
self.fill = self.fill_value
warn(
"`fill_value` deprecated. Use `fill` instead.",
DeprecationWarning,
stacklevel=2,
)
return self

def __init__(
self,
channel_drop_range: tuple[int, int] = (1, 1),
fill_value: float | None = None,
fill: float = 0,
p: float = 0.5,
):
Expand Down
Loading