hysts HF staff commited on
Commit
06d6d46
1 Parent(s): d5479f6
app_canny.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -50,10 +50,9 @@ def create_demo(process):
50
  step=0.1)
51
  seed = gr.Slider(label='Seed',
52
  minimum=0,
53
- maximum=1000000,
54
  step=1,
55
- value=0,
56
- randomize=True)
57
  randomize_seed = gr.Checkbox(label='Randomize seed',
58
  value=True)
59
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
50
  step=0.1)
51
  seed = gr.Slider(label='Seed',
52
  minimum=0,
53
+ maximum=MAX_SEED,
54
  step=1,
55
+ value=0)
 
56
  randomize_seed = gr.Checkbox(label='Randomize seed',
57
  value=True)
58
  a_prompt = gr.Textbox(
app_depth.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -49,10 +49,9 @@ def create_demo(process):
49
  step=0.1)
50
  seed = gr.Slider(label='Seed',
51
  minimum=0,
52
- maximum=1000000,
53
  step=1,
54
- value=0,
55
- randomize=True)
56
  randomize_seed = gr.Checkbox(label='Randomize seed',
57
  value=True)
58
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
49
  step=0.1)
50
  seed = gr.Slider(label='Seed',
51
  minimum=0,
52
+ maximum=MAX_SEED,
53
  step=1,
54
+ value=0)
 
55
  randomize_seed = gr.Checkbox(label='Randomize seed',
56
  value=True)
57
  a_prompt = gr.Textbox(
app_ip2p.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -38,10 +38,9 @@ def create_demo(process):
38
  step=0.1)
39
  seed = gr.Slider(label='Seed',
40
  minimum=0,
41
- maximum=1000000,
42
  step=1,
43
- value=0,
44
- randomize=True)
45
  randomize_seed = gr.Checkbox(label='Randomize seed',
46
  value=True)
47
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
38
  step=0.1)
39
  seed = gr.Slider(label='Seed',
40
  minimum=0,
41
+ maximum=MAX_SEED,
42
  step=1,
43
+ value=0)
 
44
  randomize_seed = gr.Checkbox(label='Randomize seed',
45
  value=True)
46
  a_prompt = gr.Textbox(
app_lineart.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -58,10 +58,9 @@ def create_demo(process):
58
  step=0.1)
59
  seed = gr.Slider(label='Seed',
60
  minimum=0,
61
- maximum=1000000,
62
  step=1,
63
- value=0,
64
- randomize=True)
65
  randomize_seed = gr.Checkbox(label='Randomize seed',
66
  value=True)
67
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
58
  step=0.1)
59
  seed = gr.Slider(label='Seed',
60
  minimum=0,
61
+ maximum=MAX_SEED,
62
  step=1,
63
+ value=0)
 
64
  randomize_seed = gr.Checkbox(label='Randomize seed',
65
  value=True)
66
  a_prompt = gr.Textbox(
app_mlsd.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -56,10 +56,9 @@ def create_demo(process):
56
  step=0.1)
57
  seed = gr.Slider(label='Seed',
58
  minimum=0,
59
- maximum=1000000,
60
  step=1,
61
- value=0,
62
- randomize=True)
63
  randomize_seed = gr.Checkbox(label='Randomize seed',
64
  value=True)
65
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
56
  step=0.1)
57
  seed = gr.Slider(label='Seed',
58
  minimum=0,
59
+ maximum=MAX_SEED,
60
  step=1,
61
+ value=0)
 
62
  randomize_seed = gr.Checkbox(label='Randomize seed',
63
  value=True)
64
  a_prompt = gr.Textbox(
app_normal.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -48,10 +48,9 @@ def create_demo(process):
48
  step=0.1)
49
  seed = gr.Slider(label='Seed',
50
  minimum=0,
51
- maximum=1000000,
52
  step=1,
53
- value=0,
54
- randomize=True)
55
  randomize_seed = gr.Checkbox(label='Randomize seed',
56
  value=True)
57
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
48
  step=0.1)
49
  seed = gr.Slider(label='Seed',
50
  minimum=0,
51
+ maximum=MAX_SEED,
52
  step=1,
53
+ value=0)
 
54
  randomize_seed = gr.Checkbox(label='Randomize seed',
55
  value=True)
56
  a_prompt = gr.Textbox(
app_openpose.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -48,10 +48,9 @@ def create_demo(process):
48
  step=0.1)
49
  seed = gr.Slider(label='Seed',
50
  minimum=0,
51
- maximum=1000000,
52
  step=1,
53
- value=0,
54
- randomize=True)
55
  randomize_seed = gr.Checkbox(label='Randomize seed',
56
  value=True)
57
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
48
  step=0.1)
49
  seed = gr.Slider(label='Seed',
50
  minimum=0,
51
+ maximum=MAX_SEED,
52
  step=1,
53
+ value=0)
 
54
  randomize_seed = gr.Checkbox(label='Randomize seed',
55
  value=True)
56
  a_prompt = gr.Textbox(
app_scribble.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -49,10 +49,9 @@ def create_demo(process):
49
  step=0.1)
50
  seed = gr.Slider(label='Seed',
51
  minimum=0,
52
- maximum=1000000,
53
  step=1,
54
- value=0,
55
- randomize=True)
56
  randomize_seed = gr.Checkbox(label='Randomize seed',
57
  value=True)
58
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
49
  step=0.1)
50
  seed = gr.Slider(label='Seed',
51
  minimum=0,
52
+ maximum=MAX_SEED,
53
  step=1,
54
+ value=0)
 
55
  randomize_seed = gr.Checkbox(label='Randomize seed',
56
  value=True)
57
  a_prompt = gr.Textbox(
app_scribble_interactive.py CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
4
  import numpy as np
5
 
6
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
7
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
8
  from utils import randomize_seed_fn
9
 
10
 
@@ -54,10 +54,9 @@ def create_demo(process):
54
  step=0.1)
55
  seed = gr.Slider(label='Seed',
56
  minimum=0,
57
- maximum=1000000,
58
  step=1,
59
- value=0,
60
- randomize=True)
61
  randomize_seed = gr.Checkbox(label='Randomize seed',
62
  value=True)
63
  a_prompt = gr.Textbox(
 
4
  import numpy as np
5
 
6
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
7
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
8
  from utils import randomize_seed_fn
9
 
10
 
 
54
  step=0.1)
55
  seed = gr.Slider(label='Seed',
56
  minimum=0,
57
+ maximum=MAX_SEED,
58
  step=1,
59
+ value=0)
 
60
  randomize_seed = gr.Checkbox(label='Randomize seed',
61
  value=True)
62
  a_prompt = gr.Textbox(
app_segmentation.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -48,10 +48,9 @@ def create_demo(process):
48
  step=0.1)
49
  seed = gr.Slider(label='Seed',
50
  minimum=0,
51
- maximum=1000000,
52
  step=1,
53
- value=0,
54
- randomize=True)
55
  randomize_seed = gr.Checkbox(label='Randomize seed',
56
  value=True)
57
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
48
  step=0.1)
49
  seed = gr.Slider(label='Seed',
50
  minimum=0,
51
+ maximum=MAX_SEED,
52
  step=1,
53
+ value=0)
 
54
  randomize_seed = gr.Checkbox(label='Randomize seed',
55
  value=True)
56
  a_prompt = gr.Textbox(
app_shuffle.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -43,10 +43,9 @@ def create_demo(process):
43
  step=0.1)
44
  seed = gr.Slider(label='Seed',
45
  minimum=0,
46
- maximum=1000000,
47
  step=1,
48
- value=0,
49
- randomize=True)
50
  randomize_seed = gr.Checkbox(label='Randomize seed',
51
  value=True)
52
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
43
  step=0.1)
44
  seed = gr.Slider(label='Seed',
45
  minimum=0,
46
+ maximum=MAX_SEED,
47
  step=1,
48
+ value=0)
 
49
  randomize_seed = gr.Checkbox(label='Randomize seed',
50
  value=True)
51
  a_prompt = gr.Textbox(
app_softedge.py CHANGED
@@ -3,7 +3,7 @@
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
- MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES)
7
  from utils import randomize_seed_fn
8
 
9
 
@@ -54,10 +54,9 @@ def create_demo(process):
54
  step=0.1)
55
  seed = gr.Slider(label='Seed',
56
  minimum=0,
57
- maximum=1000000,
58
  step=1,
59
- value=0,
60
- randomize=True)
61
  randomize_seed = gr.Checkbox(label='Randomize seed',
62
  value=True)
63
  a_prompt = gr.Textbox(
 
3
  import gradio as gr
4
 
5
  from settings import (DEFAULT_IMAGE_RESOLUTION, DEFAULT_NUM_IMAGES,
6
+ MAX_IMAGE_RESOLUTION, MAX_NUM_IMAGES, MAX_SEED)
7
  from utils import randomize_seed_fn
8
 
9
 
 
54
  step=0.1)
55
  seed = gr.Slider(label='Seed',
56
  minimum=0,
57
+ maximum=MAX_SEED,
58
  step=1,
59
+ value=0)
 
60
  randomize_seed = gr.Checkbox(label='Randomize seed',
61
  value=True)
62
  a_prompt = gr.Textbox(
settings.py CHANGED
@@ -1,5 +1,7 @@
1
  import os
2
 
 
 
3
  DEFAULT_MODEL_ID = os.getenv('DEFAULT_MODEL_ID',
4
  'runwayml/stable-diffusion-v1-5')
5
 
@@ -11,3 +13,5 @@ DEFAULT_IMAGE_RESOLUTION = int(os.getenv('DEFAULT_IMAGE_RESOLUTION', '768'))
11
 
12
  ALLOW_CHANGING_BASE_MODEL = os.getenv('SPACE_ID') != 'hysts/ControlNet-v1-1'
13
  SHOW_DUPLICATE_BUTTON = os.getenv('SHOW_DUPLICATE_BUTTON') == '1'
 
 
 
1
  import os
2
 
3
+ import numpy as np
4
+
5
  DEFAULT_MODEL_ID = os.getenv('DEFAULT_MODEL_ID',
6
  'runwayml/stable-diffusion-v1-5')
7
 
 
13
 
14
  ALLOW_CHANGING_BASE_MODEL = os.getenv('SPACE_ID') != 'hysts/ControlNet-v1-1'
15
  SHOW_DUPLICATE_BUTTON = os.getenv('SHOW_DUPLICATE_BUTTON') == '1'
16
+
17
+ MAX_SEED = np.iinfo(np.int32).max
utils.py CHANGED
@@ -1,7 +1,9 @@
1
  import random
2
 
 
 
3
 
4
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
5
  if randomize_seed:
6
- seed = random.randint(0, 1000000)
7
  return seed
 
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