Spaces:
Sleeping
Sleeping
Commit
·
48c3adb
1
Parent(s):
bfe0d0b
refactor
Browse files
anime_app.py
CHANGED
|
@@ -2,6 +2,7 @@ prod = True
|
|
| 2 |
show_options = True
|
| 3 |
if prod:
|
| 4 |
show_options = False
|
|
|
|
| 5 |
import gc
|
| 6 |
import random
|
| 7 |
import time
|
|
@@ -17,7 +18,9 @@ from diffusers import (
|
|
| 17 |
StableDiffusionControlNetPipeline,
|
| 18 |
)
|
| 19 |
from preprocess_anime import Preprocessor
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
print("CUDA version:", torch.version.cuda)
|
| 23 |
print("loading pipe")
|
|
@@ -102,7 +105,7 @@ def get_prompt(prompt, additional_prompt):
|
|
| 102 |
pet_play = "hyperrealistic photography, extremely detailed, playful, blush, glasses, collar, score_9, HDA_pet_play"
|
| 103 |
bondage = "hyperrealistic photography, extremely detailed, submissive, glasses, score_9, HDA_Bondage"
|
| 104 |
# ahegao = "((invisible clothing)), hyperrealistic photography,exposed vagina,sexy,nsfw,HDA_Ahegao"
|
| 105 |
-
|
| 106 |
athleisure = "hyperrealistic photography, extremely detailed, 1girl athlete, exhausted embarrassed sweaty,outdoors, ((athleisure clothing)), score_9"
|
| 107 |
atompunk = "((atompunk world)), hyperrealistic photography, extremely detailed, short hair, bodysuit, glasses, neon cyberpunk background, score_9"
|
| 108 |
maid = "hyperrealistic photography, extremely detailed, shy, blushing, score_9, pastel background, HDA_unconventional_maid"
|
|
@@ -113,8 +116,8 @@ def get_prompt(prompt, additional_prompt):
|
|
| 113 |
shibari2 = "extremely detailed, hyperrealistic photography,earrings,tattoo,score_9, HDA_Shibari"
|
| 114 |
|
| 115 |
if prompt == "":
|
| 116 |
-
prompts = [randomize, pet_play, bondage, lab_girl, athleisure, atompunk, maid, nundress, naked_hoodie, abg, shibari2]
|
| 117 |
-
prompts_nsfw = [abg, shibari2]
|
| 118 |
preset = random.choice(prompts)
|
| 119 |
prompt = f"{preset}"
|
| 120 |
# print(f"-------------{preset}-------------")
|
|
@@ -124,6 +127,7 @@ def get_prompt(prompt, additional_prompt):
|
|
| 124 |
print(f"{prompt}")
|
| 125 |
return prompt
|
| 126 |
|
|
|
|
| 127 |
@spaces.GPU(duration=20)
|
| 128 |
@torch.inference_mode()
|
| 129 |
def process_image(
|
|
@@ -137,10 +141,10 @@ def process_image(
|
|
| 137 |
num_steps,
|
| 138 |
guidance_scale,
|
| 139 |
seed,
|
|
|
|
| 140 |
):
|
| 141 |
print("processing image")
|
| 142 |
start = time.time()
|
| 143 |
-
|
| 144 |
preprocessor.load("NormalBae")
|
| 145 |
# preprocessor.load("Canny") #20 steps, 9 guidance, 512, 512
|
| 146 |
|
|
@@ -152,6 +156,7 @@ def process_image(
|
|
| 152 |
custom_prompt=str(get_prompt(prompt, a_prompt))
|
| 153 |
negative_prompt=str(n_prompt)
|
| 154 |
global compiled
|
|
|
|
| 155 |
generator = torch.cuda.manual_seed(seed)
|
| 156 |
if not compiled:
|
| 157 |
print("Not Compiled")
|
|
@@ -168,8 +173,8 @@ def process_image(
|
|
| 168 |
print(f"\n-------------------------Processed in: {time.time() - start:.2f} seconds-------------------------")
|
| 169 |
|
| 170 |
timestamp = int(time.time())
|
| 171 |
-
img_path = f"{timestamp}.jpg"
|
| 172 |
-
results_path = f"{timestamp}_out_{prompt}.jpg"
|
| 173 |
imageio.imsave(img_path, image)
|
| 174 |
results.save(results_path)
|
| 175 |
results.save("temp_image.jpg")
|
|
@@ -190,9 +195,6 @@ def process_image(
|
|
| 190 |
token=API_KEY,
|
| 191 |
run_as_future=True,
|
| 192 |
)
|
| 193 |
-
|
| 194 |
-
# torch.cuda.empty_cache()
|
| 195 |
-
# gc.collect()
|
| 196 |
|
| 197 |
return results
|
| 198 |
|
|
@@ -216,7 +218,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
| 216 |
with gr.Row():
|
| 217 |
with gr.Accordion("Advanced options", open=show_options, visible=show_options):
|
| 218 |
num_images = gr.Slider(
|
| 219 |
-
label="Images", minimum=1, maximum=
|
| 220 |
)
|
| 221 |
image_resolution = gr.Slider(
|
| 222 |
label="Image resolution",
|
|
@@ -274,7 +276,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
| 274 |
label="Anime AI",
|
| 275 |
interactive=False,
|
| 276 |
format="webp",
|
| 277 |
-
visible = True,
|
| 278 |
show_share_button= False,
|
| 279 |
)
|
| 280 |
# Use this image button
|
|
@@ -293,89 +294,38 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
| 293 |
seed,
|
| 294 |
]
|
| 295 |
|
| 296 |
-
@gr.on(triggers=[image.upload], inputs=config, outputs=[result])
|
| 297 |
-
def auto_process_image(image, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed):
|
| 298 |
-
seed = randomize_seed_fn(seed, randomize_seed)
|
| 299 |
-
return process_image(image, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
|
| 300 |
-
|
| 301 |
-
@gr.on(triggers=[image.upload], inputs=None, outputs=[use_ai_button, run_button])
|
| 302 |
-
def turn_buttons_off():
|
| 303 |
-
return gr.update(visible=False), gr.update(visible=False)
|
| 304 |
-
|
| 305 |
-
@gr.on(triggers=[use_ai_button.click], inputs=None, outputs=[use_ai_button, run_button])
|
| 306 |
-
def turn_buttons_off():
|
| 307 |
-
return gr.update(visible=False), gr.update(visible=False)
|
| 308 |
-
|
| 309 |
-
@gr.on(triggers=[run_button.click], inputs=None, outputs=[use_ai_button, run_button])
|
| 310 |
-
def turn_buttons_off():
|
| 311 |
-
return gr.update(visible=False), gr.update(visible=False)
|
| 312 |
-
|
| 313 |
-
@gr.on(triggers=[result.change], inputs=None, outputs=[use_ai_button, run_button])
|
| 314 |
-
def turn_buttons_on():
|
| 315 |
-
return gr.update(visible=True), gr.update(visible=True)
|
| 316 |
-
|
| 317 |
with gr.Row():
|
| 318 |
helper_text = gr.Markdown("## Tap and hold (on mobile) to save the image.", visible=True)
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
inputs=config,
|
| 330 |
-
outputs=result,
|
| 331 |
-
api_name=False,
|
| 332 |
-
show_progress="minimal",
|
| 333 |
-
)
|
| 334 |
-
|
| 335 |
-
run_button.click(
|
| 336 |
-
fn=randomize_seed_fn,
|
| 337 |
-
inputs=[seed, randomize_seed],
|
| 338 |
-
outputs=seed,
|
| 339 |
-
queue=False,
|
| 340 |
-
api_name=False,
|
| 341 |
-
show_progress="none",
|
| 342 |
-
).then(
|
| 343 |
-
fn=process_image,
|
| 344 |
-
inputs=config,
|
| 345 |
-
outputs=result,
|
| 346 |
-
show_progress="minimal",
|
| 347 |
-
)
|
| 348 |
|
| 349 |
-
|
|
|
|
|
|
|
| 350 |
try:
|
| 351 |
print("Updating image to AI Temp Image")
|
| 352 |
-
# Read the image from the file
|
| 353 |
ai_temp_image = Image.open("temp_image.jpg")
|
| 354 |
return ai_temp_image
|
| 355 |
except FileNotFoundError:
|
| 356 |
print("No AI Image Available")
|
| 357 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
queue=False,
|
| 364 |
-
api_name=False,
|
| 365 |
-
show_progress="none",
|
| 366 |
-
).then(
|
| 367 |
-
fn=lambda _: update_config(),
|
| 368 |
-
inputs=[image],
|
| 369 |
-
outputs=image,
|
| 370 |
-
queue=False,
|
| 371 |
-
show_progress="minimal",
|
| 372 |
-
).then(
|
| 373 |
-
fn=process_image,
|
| 374 |
-
inputs=[image, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed],
|
| 375 |
-
outputs=result,
|
| 376 |
-
queue=False,
|
| 377 |
-
show_progress="minimal",
|
| 378 |
-
)
|
| 379 |
|
| 380 |
-
|
| 381 |
demo.queue(api_open=False).launch(show_api=False)
|
|
|
|
| 2 |
show_options = True
|
| 3 |
if prod:
|
| 4 |
show_options = False
|
| 5 |
+
import os
|
| 6 |
import gc
|
| 7 |
import random
|
| 8 |
import time
|
|
|
|
| 18 |
StableDiffusionControlNetPipeline,
|
| 19 |
)
|
| 20 |
from preprocess_anime import Preprocessor
|
| 21 |
+
# MAX_SEED = np.iinfo(np.int32).max
|
| 22 |
+
MAX_SEED = 2147483647
|
| 23 |
+
API_KEY = os.environ.get("API_KEY", None)
|
| 24 |
|
| 25 |
print("CUDA version:", torch.version.cuda)
|
| 26 |
print("loading pipe")
|
|
|
|
| 105 |
pet_play = "hyperrealistic photography, extremely detailed, playful, blush, glasses, collar, score_9, HDA_pet_play"
|
| 106 |
bondage = "hyperrealistic photography, extremely detailed, submissive, glasses, score_9, HDA_Bondage"
|
| 107 |
# ahegao = "((invisible clothing)), hyperrealistic photography,exposed vagina,sexy,nsfw,HDA_Ahegao"
|
| 108 |
+
ahegao2 = "(invisiblebodypaint),rating_newd,HDA_Ahegao"
|
| 109 |
athleisure = "hyperrealistic photography, extremely detailed, 1girl athlete, exhausted embarrassed sweaty,outdoors, ((athleisure clothing)), score_9"
|
| 110 |
atompunk = "((atompunk world)), hyperrealistic photography, extremely detailed, short hair, bodysuit, glasses, neon cyberpunk background, score_9"
|
| 111 |
maid = "hyperrealistic photography, extremely detailed, shy, blushing, score_9, pastel background, HDA_unconventional_maid"
|
|
|
|
| 116 |
shibari2 = "extremely detailed, hyperrealistic photography,earrings,tattoo,score_9, HDA_Shibari"
|
| 117 |
|
| 118 |
if prompt == "":
|
| 119 |
+
prompts = [randomize, pet_play, bondage, lab_girl, athleisure, atompunk, maid, nundress, naked_hoodie, abg, shibari2, ahegao2]
|
| 120 |
+
prompts_nsfw = [abg, shibari2, ahegao2]
|
| 121 |
preset = random.choice(prompts)
|
| 122 |
prompt = f"{preset}"
|
| 123 |
# print(f"-------------{preset}-------------")
|
|
|
|
| 127 |
print(f"{prompt}")
|
| 128 |
return prompt
|
| 129 |
|
| 130 |
+
|
| 131 |
@spaces.GPU(duration=20)
|
| 132 |
@torch.inference_mode()
|
| 133 |
def process_image(
|
|
|
|
| 141 |
num_steps,
|
| 142 |
guidance_scale,
|
| 143 |
seed,
|
| 144 |
+
progress=gr.Progress(track_tqdm=True)
|
| 145 |
):
|
| 146 |
print("processing image")
|
| 147 |
start = time.time()
|
|
|
|
| 148 |
preprocessor.load("NormalBae")
|
| 149 |
# preprocessor.load("Canny") #20 steps, 9 guidance, 512, 512
|
| 150 |
|
|
|
|
| 156 |
custom_prompt=str(get_prompt(prompt, a_prompt))
|
| 157 |
negative_prompt=str(n_prompt)
|
| 158 |
global compiled
|
| 159 |
+
seed = random.randint(0, MAX_SEED)
|
| 160 |
generator = torch.cuda.manual_seed(seed)
|
| 161 |
if not compiled:
|
| 162 |
print("Not Compiled")
|
|
|
|
| 173 |
print(f"\n-------------------------Processed in: {time.time() - start:.2f} seconds-------------------------")
|
| 174 |
|
| 175 |
timestamp = int(time.time())
|
| 176 |
+
img_path = f"./outputs/{timestamp}.jpg"
|
| 177 |
+
results_path = f"./outputs/{timestamp}_out_{prompt}.jpg"
|
| 178 |
imageio.imsave(img_path, image)
|
| 179 |
results.save(results_path)
|
| 180 |
results.save("temp_image.jpg")
|
|
|
|
| 195 |
token=API_KEY,
|
| 196 |
run_as_future=True,
|
| 197 |
)
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
return results
|
| 200 |
|
|
|
|
| 218 |
with gr.Row():
|
| 219 |
with gr.Accordion("Advanced options", open=show_options, visible=show_options):
|
| 220 |
num_images = gr.Slider(
|
| 221 |
+
label="Images", minimum=1, maximum=4, value=1, step=1
|
| 222 |
)
|
| 223 |
image_resolution = gr.Slider(
|
| 224 |
label="Image resolution",
|
|
|
|
| 276 |
label="Anime AI",
|
| 277 |
interactive=False,
|
| 278 |
format="webp",
|
|
|
|
| 279 |
show_share_button= False,
|
| 280 |
)
|
| 281 |
# Use this image button
|
|
|
|
| 294 |
seed,
|
| 295 |
]
|
| 296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
with gr.Row():
|
| 298 |
helper_text = gr.Markdown("## Tap and hold (on mobile) to save the image.", visible=True)
|
| 299 |
+
|
| 300 |
+
# image processing
|
| 301 |
+
@gr.on(triggers=[image.upload, prompt.submit, run_button.click], inputs=config, outputs=result, show_progress="minimal")
|
| 302 |
+
def auto_process_image(image, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
|
| 303 |
+
return process_image(image, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
|
| 304 |
+
|
| 305 |
+
# AI Image Processing
|
| 306 |
+
@gr.on(triggers=[use_ai_button.click], inputs=config, outputs=result, show_progress="minimal")
|
| 307 |
+
def submit(image, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
|
| 308 |
+
return process_image(image, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
+
# Change input to result
|
| 311 |
+
@gr.on(triggers=[use_ai_button.click], inputs=None, outputs=image, show_progress="hidden")
|
| 312 |
+
def update_input():
|
| 313 |
try:
|
| 314 |
print("Updating image to AI Temp Image")
|
|
|
|
| 315 |
ai_temp_image = Image.open("temp_image.jpg")
|
| 316 |
return ai_temp_image
|
| 317 |
except FileNotFoundError:
|
| 318 |
print("No AI Image Available")
|
| 319 |
return None
|
| 320 |
+
|
| 321 |
+
# Turn off buttons when processing
|
| 322 |
+
@gr.on(triggers=[image.upload, use_ai_button.click, run_button.click], inputs=None, outputs=[run_button, use_ai_button], show_progress="hidden")
|
| 323 |
+
def turn_buttons_off():
|
| 324 |
+
return gr.update(visible=False), gr.update(visible=False)
|
| 325 |
|
| 326 |
+
# Turn on buttons when processing is complete
|
| 327 |
+
@gr.on(triggers=[result.change], inputs=None, outputs=[use_ai_button, run_button], show_progress="hidden")
|
| 328 |
+
def turn_buttons_on():
|
| 329 |
+
return gr.update(visible=True), gr.update(visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
|
|
|
|
| 331 |
demo.queue(api_open=False).launch(show_api=False)
|
controlnet_aux/normalbae/__pycache__/__init__.cpython-310.pyc
CHANGED
|
Binary files a/controlnet_aux/normalbae/__pycache__/__init__.cpython-310.pyc and b/controlnet_aux/normalbae/__pycache__/__init__.cpython-310.pyc differ
|
|
|
controlnet_aux/normalbae/nets/submodules/efficientnet_repo/geffnet/activations/__pycache__/activations_me.cpython-310.pyc
CHANGED
|
Binary files a/controlnet_aux/normalbae/nets/submodules/efficientnet_repo/geffnet/activations/__pycache__/activations_me.cpython-310.pyc and b/controlnet_aux/normalbae/nets/submodules/efficientnet_repo/geffnet/activations/__pycache__/activations_me.cpython-310.pyc differ
|
|
|
cv_utils.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
import cv2
|
| 2 |
-
import numpy as np
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
def resize_image(input_image, resolution, interpolation=None):
|
| 6 |
-
H, W, C = input_image.shape
|
| 7 |
-
H = float(H)
|
| 8 |
-
W = float(W)
|
| 9 |
-
k = float(resolution) / max(H, W)
|
| 10 |
-
H *= k
|
| 11 |
-
W *= k
|
| 12 |
-
H = int(np.round(H / 64.0)) * 64
|
| 13 |
-
W = int(np.round(W / 64.0)) * 64
|
| 14 |
-
if interpolation is None:
|
| 15 |
-
interpolation = cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA
|
| 16 |
-
img = cv2.resize(input_image, (W, H), interpolation=interpolation)
|
| 17 |
-
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preprocess_anime.py
CHANGED
|
@@ -6,10 +6,26 @@ import torch
|
|
| 6 |
from controlnet_aux import NormalBaeDetector#, CannyDetector
|
| 7 |
|
| 8 |
from controlnet_aux.util import HWC3
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
class Preprocessor:
|
| 12 |
MODEL_ID = "lllyasviel/Annotators"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def __init__(self):
|
| 15 |
self.model = None
|
|
|
|
| 6 |
from controlnet_aux import NormalBaeDetector#, CannyDetector
|
| 7 |
|
| 8 |
from controlnet_aux.util import HWC3
|
| 9 |
+
import cv2
|
| 10 |
+
# from cv_utils import resize_image
|
| 11 |
|
| 12 |
class Preprocessor:
|
| 13 |
MODEL_ID = "lllyasviel/Annotators"
|
| 14 |
+
|
| 15 |
+
def resize_image(input_image, resolution, interpolation=None):
|
| 16 |
+
H, W, C = input_image.shape
|
| 17 |
+
H = float(H)
|
| 18 |
+
W = float(W)
|
| 19 |
+
k = float(resolution) / max(H, W)
|
| 20 |
+
H *= k
|
| 21 |
+
W *= k
|
| 22 |
+
H = int(np.round(H / 64.0)) * 64
|
| 23 |
+
W = int(np.round(W / 64.0)) * 64
|
| 24 |
+
if interpolation is None:
|
| 25 |
+
interpolation = cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA
|
| 26 |
+
img = cv2.resize(input_image, (W, H), interpolation=interpolation)
|
| 27 |
+
return img
|
| 28 |
+
|
| 29 |
|
| 30 |
def __init__(self):
|
| 31 |
self.model = None
|
settings.py
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
|
| 3 |
-
import numpy as np
|
| 4 |
-
|
| 5 |
-
DEFAULT_MODEL_ID = os.getenv("DEFAULT_MODEL_ID", "runwayml/stable-diffusion-v1-5")
|
| 6 |
-
# DEFAULT_MODEL_ID = ("runwayml/stable-diffusion-v1-5")
|
| 7 |
-
MAX_NUM_IMAGES = int(os.getenv("MAX_NUM_IMAGES", "4"))
|
| 8 |
-
DEFAULT_NUM_IMAGES = min(MAX_NUM_IMAGES, int(os.getenv("DEFAULT_NUM_IMAGES", "1")))
|
| 9 |
-
MAX_IMAGE_RESOLUTION = int(os.getenv("MAX_IMAGE_RESOLUTION", "1024"))
|
| 10 |
-
DEFAULT_IMAGE_RESOLUTION = min(MAX_IMAGE_RESOLUTION, int(os.getenv("DEFAULT_IMAGE_RESOLUTION", "512")))
|
| 11 |
-
|
| 12 |
-
ALLOW_CHANGING_BASE_MODEL = os.getenv("SPACE_ID") != "hysts/ControlNet-v1-1"
|
| 13 |
-
SHOW_DUPLICATE_BUTTON = os.getenv("SHOW_DUPLICATE_BUTTON") == "1"
|
| 14 |
-
|
| 15 |
-
MAX_SEED = np.iinfo(np.int32).max
|
| 16 |
-
API_KEY = os.environ["API_KEY"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import random
|
| 2 |
-
|
| 3 |
-
from settings import MAX_SEED
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
| 7 |
-
if randomize_seed:
|
| 8 |
-
seed = random.randint(0, MAX_SEED)
|
| 9 |
-
return seed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|