Enhance get_seed function documentation to clarify its purpose, arguments, return values, and usage notes for improved understanding and reproducibility in model generation.
Browse files
app.py
CHANGED
|
@@ -107,8 +107,22 @@ def load_state_from_file(state_path: str) -> tuple[Gaussian, EasyDict]:
|
|
| 107 |
|
| 108 |
|
| 109 |
def get_seed(randomize_seed: bool, seed: int) -> int:
|
| 110 |
-
"""
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
|
| 114 |
@spaces.GPU
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
def get_seed(randomize_seed: bool, seed: int) -> int:
|
| 110 |
+
"""Determine and return the random seed to use for model generation or sampling.
|
| 111 |
+
|
| 112 |
+
Args:
|
| 113 |
+
randomize_seed (bool): If True, a random seed (an integer in [0, MAX_SEED)) is generated using NumPy's default random number generator. If False, the provided seed argument is returned as-is.
|
| 114 |
+
seed (int): The seed value to use if randomize_seed is False.
|
| 115 |
+
|
| 116 |
+
Returns:
|
| 117 |
+
int: The selected seed value. If randomize_seed is True, a randomly generated integer; otherwise, the value of the seed argument.
|
| 118 |
+
|
| 119 |
+
Notes:
|
| 120 |
+
- MAX_SEED is the maximum value for a 32-bit integer (np.iinfo(np.int32).max).
|
| 121 |
+
- This function is typically used to ensure reproducibility or to introduce randomness in model generation.
|
| 122 |
+
- The random seed affects the stochastic processes in downstream model inference or sampling.
|
| 123 |
+
"""
|
| 124 |
+
rng = np.random.default_rng()
|
| 125 |
+
return rng.integers(0, MAX_SEED) if randomize_seed else seed
|
| 126 |
|
| 127 |
|
| 128 |
@spaces.GPU
|