Skip to content

Commit

Permalink
fix RandomGenerator bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chflame163 committed Oct 12, 2024
1 parent 5b0d9c3 commit f9b83c3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions py/random_generator.py
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit f9b83c3

Please sign in to comment.