Spaces:
Sleeping
Sleeping
Pedro Cuenca
commited on
Commit
·
4575fad
1
Parent(s):
4c2d7ed
Fake seeds
Browse files
app.py
CHANGED
@@ -7,12 +7,14 @@ from collections import defaultdict
|
|
7 |
from functools import partial
|
8 |
from PIL import Image
|
9 |
|
10 |
-
block = gr.Blocks(css=".container { max-width: 800px; margin: auto; }")
|
11 |
-
|
12 |
SELECT_LABEL = "Select as seed"
|
13 |
selectors: List[gr.Radio] = []
|
|
|
|
|
|
|
14 |
|
15 |
def infer_seeded_image(prompt, seed):
|
|
|
16 |
return Image.open(f"sample_outputs/seeded_1.png")
|
17 |
|
18 |
def infer_grid(prompt):
|
@@ -21,8 +23,8 @@ def infer_grid(prompt):
|
|
21 |
response["images"].append(Image.open(f"sample_outputs/{i}.png"))
|
22 |
response["seeds"].append(random.randint(0, 2 ** 32 -1))
|
23 |
|
24 |
-
|
25 |
-
|
26 |
return response["images"]
|
27 |
|
28 |
def infer(prompt):
|
@@ -37,8 +39,9 @@ def infer(prompt):
|
|
37 |
image_with_seed = None
|
38 |
visible = (False, False)
|
39 |
|
40 |
-
if current_selection() > -1:
|
41 |
-
|
|
|
42 |
visible = (False, True)
|
43 |
else:
|
44 |
grid_images = infer_grid(prompt)
|
|
|
7 |
from functools import partial
|
8 |
from PIL import Image
|
9 |
|
|
|
|
|
10 |
SELECT_LABEL = "Select as seed"
|
11 |
selectors: List[gr.Radio] = []
|
12 |
+
seeds = []
|
13 |
+
|
14 |
+
block = gr.Blocks(css=".container { max-width: 800px; margin: auto; }")
|
15 |
|
16 |
def infer_seeded_image(prompt, seed):
|
17 |
+
print(f"Prompt: {prompt}, seed: {seed}")
|
18 |
return Image.open(f"sample_outputs/seeded_1.png")
|
19 |
|
20 |
def infer_grid(prompt):
|
|
|
23 |
response["images"].append(Image.open(f"sample_outputs/{i}.png"))
|
24 |
response["seeds"].append(random.randint(0, 2 ** 32 -1))
|
25 |
|
26 |
+
global seeds
|
27 |
+
seeds = response["seeds"]
|
28 |
return response["images"]
|
29 |
|
30 |
def infer(prompt):
|
|
|
39 |
image_with_seed = None
|
40 |
visible = (False, False)
|
41 |
|
42 |
+
if seed_index := current_selection() > -1:
|
43 |
+
seed = seeds[seed_index]
|
44 |
+
image_with_seed = infer_seeded_image(prompt, seed)
|
45 |
visible = (False, True)
|
46 |
else:
|
47 |
grid_images = infer_grid(prompt)
|