aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ui.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-09-05 20:08:06 +0000
committerAUTOMATIC <16777216c@gmail.com>2022-09-05 20:08:06 +0000
commitb6763fb8847df5a5678f37137e7a702569e5c925 (patch)
treea535916207766972b929de713c6d3bb1f2a2f2d8 /modules/ui.py
parentf5563853b83aa8fd60484af1c0d6a9691c887d25 (diff)
downloadstable-diffusion-webui-gfx803-b6763fb8847df5a5678f37137e7a702569e5c925.tar.gz
stable-diffusion-webui-gfx803-b6763fb8847df5a5678f37137e7a702569e5c925.tar.bz2
stable-diffusion-webui-gfx803-b6763fb8847df5a5678f37137e7a702569e5c925.zip
added random artist button
added a setting for padding when doing inpaint at original resolution
Diffstat (limited to 'modules/ui.py')
-rw-r--r--modules/ui.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/ui.py b/modules/ui.py
index ec583d14..aa5a61b7 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -4,6 +4,7 @@ import io
import json
import mimetypes
import os
+import random
import sys
import time
import traceback
@@ -133,6 +134,13 @@ def wrap_gradio_call(func):
return f
+def roll_artist(prompt):
+ allowed_cats = set([x for x in shared.artist_db.categories() if len(opts.random_artist_categories)==0 or x in opts.random_artist_categories])
+ artist = random.choice([x for x in shared.artist_db.artists if x.category in allowed_cats])
+
+ return prompt + ", " + artist.name if prompt != '' else artist.name
+
+
def visit(x, func, path=""):
if hasattr(x, 'children'):
for c in x.children:
@@ -146,6 +154,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
with gr.Row():
prompt = gr.Textbox(label="Prompt", elem_id="txt2img_prompt", show_label=False, placeholder="Prompt", lines=1)
negative_prompt = gr.Textbox(label="Negative prompt", elem_id="txt2img_negative_prompt", show_label=False, placeholder="Negative prompt", lines=1, visible=False)
+ roll = gr.Button('Roll', elem_id="txt2img_roll", visible=len(shared.artist_db.artists)>0)
submit = gr.Button('Generate', elem_id="txt2img_generate", variant='primary')
with gr.Row().style(equal_height=False):
@@ -233,6 +242,16 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
]
)
+ roll.click(
+ fn=roll_artist,
+ inputs=[
+ prompt,
+ ],
+ outputs=[
+ prompt
+ ]
+ )
+
with gr.Blocks(analytics_enabled=False) as img2img_interface:
with gr.Row():
prompt = gr.Textbox(label="Prompt", elem_id="img2img_prompt", show_label=False, placeholder="Prompt", lines=1)