Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ternaus committed Oct 25, 2024
1 parent 19b274c commit 54e8cb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion albumentations/augmentations/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2606,8 +2606,8 @@ def __init__(
def apply(
self,
img: np.ndarray,
intensity: float,
color_shift: float,
intensity: float,
random_seed: int,
**params: Any,
) -> np.ndarray:
Expand Down
11 changes: 5 additions & 6 deletions albumentations/core/transforms_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class BasicTransform(Serializable, metaclass=CombinedMeta):
class InitSchema(BaseTransformInitSchema):
pass

def __init__(self, p: float = 0.5, seed: int | None = None, always_apply: bool | None = None):
def __init__(self, p: float = 0.5, always_apply: bool | None = None):
self.p = p
if always_apply is not None:
if always_apply:
Expand All @@ -85,16 +85,15 @@ def __init__(self, p: float = 0.5, seed: int | None = None, always_apply: bool |
self._key2func = {}
self._set_keys()
self.processors: dict[str, BboxProcessor | KeypointsProcessor] = {}
self.seed = seed
self.random_generator = np.random.default_rng(seed)
self.py_random = random.Random(seed) # Create instance instead of using global
self.seed: int | None = None
self.random_generator = np.random.default_rng(self.seed)
self.py_random = random.Random(self.seed) # Create instance instead of using global

def set_random_state(self, seed: int | None, recursive: bool = True) -> None:
def set_random_state(self, seed: int) -> None:
"""Set random state for this transform and all nested transforms.
Args:
seed: Random seed to use
recursive: Whether to set random state for nested transforms
"""
self.seed = seed
self.random_generator = np.random.default_rng(seed)
Expand Down

0 comments on commit 54e8cb9

Please sign in to comment.