From f9b83c393f0d7531f7859c8fa2d78c2609aca405 Mon Sep 17 00:00:00 2001 From: macro chen Date: Sat, 12 Oct 2024 16:02:20 +0800 Subject: [PATCH] fix RandomGenerator bug --- py/random_generator.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/py/random_generator.py b/py/random_generator.py index eeb54a3..9f4d6c5 100644 --- a/py/random_generator.py +++ b/py/random_generator.py @@ -1,12 +1,6 @@ from .imagefunc import AnyType import random -def generate_unique_seed() -> int: - while True: - new_number = random.randint(0, 1e14) - if new_number not in self.previous_seeds: - self.previous_seeds.add(new_number) - return new_number class LSRandomGenerator: @@ -42,7 +36,7 @@ def random_generator(self, min_value, max_value, float_decimal_places, fix_seed, batch_size = image.shape[0] ret_nunbers = [] for i in range(batch_size): - new_seed = generate_unique_seed() + new_seed = self.generate_unique_seed() if fix_seed: if self.fixed_seed == 0: self.fixed_seed = new_seed @@ -65,6 +59,14 @@ def random_generator(self, min_value, max_value, float_decimal_places, fix_seed, else: return (ret_nunbers[0][0], ret_nunbers[0][1], ret_nunbers[0][2]) + + def generate_unique_seed(self) -> int: + while True: + new_number = random.randint(0, 1e14) + if new_number not in self.previous_seeds: + self.previous_seeds.add(new_number) + return new_number + class LS_RandomGeneratorV2: def __init__(self):