Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -499,15 +499,8 @@ def draw(state, drawpad):
|
|
| 499 |
|
| 500 |
### Load examples
|
| 501 |
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
print(root)
|
| 505 |
-
example_root = os.path.join(root, 'examples')
|
| 506 |
-
example_images = glob.glob(os.path.join(example_root, '*.png'))
|
| 507 |
-
example_images = [Image.open(i) for i in example_images]
|
| 508 |
-
|
| 509 |
-
# with open(os.path.join(example_root, 'prompt_background_advanced.txt')) as f:
|
| 510 |
-
# prompts_background = [l.strip() for l in f.readlines() if l.strip() != '']
|
| 511 |
|
| 512 |
# with open(os.path.join(example_root, 'prompt_girl.txt')) as f:
|
| 513 |
# prompts_girl = [l.strip() for l in f.readlines() if l.strip() != '']
|
|
@@ -515,14 +508,14 @@ example_images = [Image.open(i) for i in example_images]
|
|
| 515 |
# with open(os.path.join(example_root, 'prompt_boy.txt')) as f:
|
| 516 |
# prompts_boy = [l.strip() for l in f.readlines() if l.strip() != '']
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
|
| 522 |
-
|
| 523 |
# prompt_girl = lambda: random.choice(prompts_girl)
|
| 524 |
# prompt_boy = lambda: random.choice(prompts_boy)
|
| 525 |
-
|
| 526 |
|
| 527 |
|
| 528 |
### Main application
|
|
@@ -658,19 +651,19 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css, head=head) as demo:
|
|
| 658 |
state.active_palettes = 5
|
| 659 |
|
| 660 |
# Front-end initialized to the default values.
|
| 661 |
-
|
| 662 |
state.prompt_names = [
|
| 663 |
'π Background',
|
| 664 |
'π§ Girl',
|
| 665 |
-
'πΆ Dog',
|
| 666 |
-
'π Garden',
|
| 667 |
-
] + ['π¨ New Palette' for _ in range(opt.max_palettes - 3)]
|
| 668 |
state.prompts = [
|
| 669 |
'',
|
| 670 |
-
|
| 671 |
-
'Doggy body part',
|
| 672 |
-
'Flower garden',
|
| 673 |
-
] + ['' for _ in range(opt.max_palettes - 3)]
|
| 674 |
state.neg_prompts = [
|
| 675 |
opt.default_negative_prompt
|
| 676 |
+ (', humans, humans, humans' if i == 0 else '')
|
|
|
|
| 499 |
|
| 500 |
### Load examples
|
| 501 |
|
| 502 |
+
with open(os.path.join(example_root, 'prompt_background.txt')) as f:
|
| 503 |
+
prompts_background = [l.strip() for l in f.readlines() if l.strip() != '']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
|
| 505 |
# with open(os.path.join(example_root, 'prompt_girl.txt')) as f:
|
| 506 |
# prompts_girl = [l.strip() for l in f.readlines() if l.strip() != '']
|
|
|
|
| 508 |
# with open(os.path.join(example_root, 'prompt_boy.txt')) as f:
|
| 509 |
# prompts_boy = [l.strip() for l in f.readlines() if l.strip() != '']
|
| 510 |
|
| 511 |
+
with open(os.path.join(example_root, 'prompt_props.txt')) as f:
|
| 512 |
+
prompts_props = [l.strip() for l in f.readlines() if l.strip() != '']
|
| 513 |
+
prompts_props = {l.split(',')[0].strip(): ','.join(l.split(',')[1:]).strip() for l in prompts_props}
|
| 514 |
|
| 515 |
+
prompt_background = lambda: random.choice(prompts_background)
|
| 516 |
# prompt_girl = lambda: random.choice(prompts_girl)
|
| 517 |
# prompt_boy = lambda: random.choice(prompts_boy)
|
| 518 |
+
prompt_props = lambda: np.random.choice(list(prompts_props.keys()), size=(opt.max_palettes - 1), replace=False).tolist()
|
| 519 |
|
| 520 |
|
| 521 |
### Main application
|
|
|
|
| 651 |
state.active_palettes = 5
|
| 652 |
|
| 653 |
# Front-end initialized to the default values.
|
| 654 |
+
prompt_props_ = prompt_props()
|
| 655 |
state.prompt_names = [
|
| 656 |
'π Background',
|
| 657 |
'π§ Girl',
|
| 658 |
+
# 'πΆ Dog',
|
| 659 |
+
# 'π Garden',
|
| 660 |
+
] + prompt_props_ + ['π¨ New Palette' for _ in range(opt.max_palettes - 3)]
|
| 661 |
state.prompts = [
|
| 662 |
'',
|
| 663 |
+
'A girl smiling at viewer',
|
| 664 |
+
# 'Doggy body part',
|
| 665 |
+
# 'Flower garden',
|
| 666 |
+
] + [prompts_props[k] for k in prompt_props_] + ['' for _ in range(opt.max_palettes - 3)]
|
| 667 |
state.neg_prompts = [
|
| 668 |
opt.default_negative_prompt
|
| 669 |
+ (', humans, humans, humans' if i == 0 else '')
|