sashavor
commited on
Commit
•
bb286fb
1
Parent(s):
3276427
updating app
Browse files
app.py
CHANGED
@@ -3,37 +3,37 @@ import random, os
|
|
3 |
from PIL import Image
|
4 |
|
5 |
def open_ims(choice):
|
6 |
-
|
7 |
-
imnames
|
8 |
-
images = [(Image.open(name)) for name in imnames]
|
9 |
-
return images
|
10 |
|
11 |
def random_image():
|
12 |
cat = random.choice(categories)
|
13 |
-
|
14 |
-
imnames = os.listdir(
|
15 |
-
|
16 |
-
|
17 |
-
print(ims)
|
18 |
-
return ims
|
19 |
|
20 |
categories=os.listdir('images/')
|
21 |
categories = [c.replace('Photo_portrait_of_a_','').replace('_',' ') for c in categories]
|
22 |
-
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
gr.Markdown("# Stable Diffusion Explorer")
|
26 |
gr.Markdown("## TODO")
|
27 |
-
|
|
|
|
|
28 |
with gr.Row():
|
29 |
with gr.Column():
|
30 |
-
|
31 |
-
|
32 |
with gr.Column():
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
demo.load(random_image, None, images)
|
37 |
-
choice.change(open_ims, [prompt], [images])
|
38 |
|
|
|
|
|
|
|
39 |
demo.launch()
|
|
|
3 |
from PIL import Image
|
4 |
|
5 |
def open_ims(choice):
|
6 |
+
dirname='images/'+'Photo_portrait_of_a_'+choice.replace(' ',' ')+'/Seed_'+ str(seed_choice)+'/'
|
7 |
+
imnames= os.listdir(dirname)
|
8 |
+
images = [(Image.open(dirname+name)) for name in imnames]
|
9 |
+
return images[:9]
|
10 |
|
11 |
def random_image():
|
12 |
cat = random.choice(categories)
|
13 |
+
dirname = 'images/'+'Photo_portrait_of_a_'+cat.replace(' ',' ')+'/Seed_'+str(seed_choice)+'/'
|
14 |
+
imnames = os.listdir(dirname)
|
15 |
+
images = [(Image.open(dirname+name)) for name in imnames]
|
16 |
+
return images[:9]
|
|
|
|
|
17 |
|
18 |
categories=os.listdir('images/')
|
19 |
categories = [c.replace('Photo_portrait_of_a_','').replace('_',' ') for c in categories]
|
20 |
+
seeds = [46267, 48040, 51237, 54325, 60884, 64830, 67031, 72935, 92118, 93109]
|
21 |
|
22 |
with gr.Blocks() as demo:
|
23 |
gr.Markdown("# Stable Diffusion Explorer")
|
24 |
gr.Markdown("## TODO")
|
25 |
+
seed_choice = gr.State(0)
|
26 |
+
seed_choice = random.choice(seeds)
|
27 |
+
print(seed_choice)
|
28 |
with gr.Row():
|
29 |
with gr.Column():
|
30 |
+
choice1 = gr.Dropdown(categories, label = "Choose a first category", interactive=True)
|
31 |
+
images1 = gr.Gallery(label="Images").style(grid=[3], height="auto")
|
32 |
with gr.Column():
|
33 |
+
choice2 = gr.Dropdown(categories, label = "Choose a second category", interactive=True)
|
34 |
+
images2 = gr.Gallery(label="Images").style(grid=[3], height="auto")
|
|
|
|
|
|
|
35 |
|
36 |
+
#demo.load(random_image, None, [images])
|
37 |
+
choice1.change(open_ims, [choice1], [images1])
|
38 |
+
choice2.change(open_ims, [choice2], [images2])
|
39 |
demo.launch()
|