lllyasviel commited on
Commit
b6016a7
1 Parent(s): df9f76e

random seed restoring

Browse files
Files changed (2) hide show
  1. modules/async_worker.py +7 -2
  2. webui.py +17 -3
modules/async_worker.py CHANGED
@@ -54,8 +54,13 @@ def worker():
54
 
55
  results = []
56
  seed = image_seed
57
- if not isinstance(seed, int) or seed < 0 or seed > 1024*1024*1024:
58
- seed = random.randint(1, 1024*1024*1024)
 
 
 
 
 
59
 
60
  all_steps = steps * image_number
61
 
 
54
 
55
  results = []
56
  seed = image_seed
57
+ max_seed = int(1024*1024*1024)
58
+
59
+ if not isinstance(seed, int):
60
+ seed = random.randint(1, max_seed)
61
+ if seed < 0:
62
+ seed = - seed
63
+ seed = seed % max_seed
64
 
65
  all_steps = steps * image_number
66
 
webui.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- import sys
3
  import time
4
  import shared
5
  import argparse
@@ -59,8 +59,21 @@ with shared.gradio_root:
59
  aspect_ratios_selction = gr.Radio(label='Aspect Ratios (width × height)', choices=list(aspect_ratios.keys()),
60
  value='1152×896')
61
  image_number = gr.Slider(label='Image Number', minimum=1, maximum=32, step=1, value=2)
62
- image_seed = gr.Number(label='Random Seed', value=-1, precision=0)
63
  negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  with gr.Tab(label='Style'):
65
  style_selction = gr.Radio(show_label=False, container=True,
66
  choices=style_keys, value='cinematic-default')
@@ -97,7 +110,8 @@ with shared.gradio_root:
97
  performance_selction, aspect_ratios_selction, image_number, image_seed, sharpness
98
  ]
99
  ctrls += [base_model, refiner_model] + lora_ctrls
100
- run_button.click(fn=generate_clicked, inputs=ctrls, outputs=[run_button, progress_html, progress_window, gallery])
 
101
 
102
 
103
  parser = argparse.ArgumentParser()
 
1
  import gradio as gr
2
+ import random
3
  import time
4
  import shared
5
  import argparse
 
59
  aspect_ratios_selction = gr.Radio(label='Aspect Ratios (width × height)', choices=list(aspect_ratios.keys()),
60
  value='1152×896')
61
  image_number = gr.Slider(label='Image Number', minimum=1, maximum=32, step=1, value=2)
 
62
  negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.")
63
+ seed_random = gr.Checkbox(label='Random', value=True)
64
+ image_seed = gr.Number(label='Seed', value=0, precision=0, visible=False)
65
+
66
+ def random_checked(r):
67
+ return gr.update(visible=not r)
68
+
69
+ def refresh_seed(r, s):
70
+ if r:
71
+ return random.randint(1, 1024*1024*1024)
72
+ else:
73
+ return s
74
+
75
+ seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed])
76
+
77
  with gr.Tab(label='Style'):
78
  style_selction = gr.Radio(show_label=False, container=True,
79
  choices=style_keys, value='cinematic-default')
 
110
  performance_selction, aspect_ratios_selction, image_number, image_seed, sharpness
111
  ]
112
  ctrls += [base_model, refiner_model] + lora_ctrls
113
+ run_button.click(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed)\
114
+ .then(fn=generate_clicked, inputs=ctrls, outputs=[run_button, progress_html, progress_window, gallery])
115
 
116
 
117
  parser = argparse.ArgumentParser()