mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-12-24 13:28:59 +01:00
Add custom prompt format for SD API pictures (#1964)
This commit is contained in:
parent
cb029cf65f
commit
40bbd53640
@ -36,9 +36,9 @@ params = {
|
||||
'sampler_name': 'DDIM',
|
||||
'steps': 32,
|
||||
'cfg_scale': 7,
|
||||
'sd_checkpoint' : ' ',
|
||||
'checkpoint_list' : [" "]
|
||||
|
||||
'textgen_prefix': 'Please provide a detailed and vivid description of [subject]',
|
||||
'sd_checkpoint': ' ',
|
||||
'checkpoint_list': [" "]
|
||||
}
|
||||
|
||||
|
||||
@ -119,14 +119,15 @@ def input_modifier(string):
|
||||
string = string.lower()
|
||||
if "of" in string:
|
||||
subject = string.split('of', 1)[1] # subdivide the string once by the first 'of' instance and get what's coming after it
|
||||
string = "Please provide a detailed and vivid description of " + subject
|
||||
string = params['textgen_prefix'].replace("[subject]", subject)
|
||||
else:
|
||||
string = "Please provide a detailed description of your appearance, your surroundings and what you are doing right now"
|
||||
string = params['textgen_prefix'].replace("[subject]", "your appearance, your surroundings and what you are doing right now")
|
||||
|
||||
return string
|
||||
|
||||
# Get and save the Stable Diffusion-generated picture
|
||||
def get_SD_pictures(description):
|
||||
|
||||
global params
|
||||
|
||||
if params['manage_VRAM']:
|
||||
@ -267,6 +268,7 @@ def custom_css():
|
||||
path_to_css = Path(__file__).parent.resolve() / 'style.css'
|
||||
return open(path_to_css, 'r').read()
|
||||
|
||||
|
||||
def get_checkpoints():
|
||||
global params
|
||||
|
||||
@ -282,6 +284,7 @@ def get_checkpoints():
|
||||
|
||||
return gr.update(choices=params['checkpoint_list'], value=params['sd_checkpoint'])
|
||||
|
||||
|
||||
def load_checkpoint(checkpoint):
|
||||
|
||||
payload = {
|
||||
@ -290,6 +293,7 @@ def load_checkpoint(checkpoint):
|
||||
|
||||
requests.post(url=f'{params["address"]}/sdapi/v1/options', json=payload)
|
||||
|
||||
|
||||
def get_samplers():
|
||||
try:
|
||||
response = requests.get(url=f'{params["address"]}/sdapi/v1/samplers')
|
||||
@ -322,6 +326,7 @@ def ui():
|
||||
|
||||
with gr.Accordion("Generation parameters", open=False):
|
||||
prompt_prefix = gr.Textbox(placeholder=params['prompt_prefix'], value=params['prompt_prefix'], label='Prompt Prefix (best used to describe the look of the character)')
|
||||
textgen_prefix = gr.Textbox(placeholder=params['textgen_prefix'], value=params['textgen_prefix'], label='textgen prefix (type [subject] where the subject should be placed)')
|
||||
negative_prompt = gr.Textbox(placeholder=params['negative_prompt'], value=params['negative_prompt'], label='Negative Prompt')
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
@ -353,6 +358,7 @@ def ui():
|
||||
|
||||
address.submit(fn=SD_api_address_update, inputs=address, outputs=address)
|
||||
prompt_prefix.change(lambda x: params.update({"prompt_prefix": x}), prompt_prefix, None)
|
||||
textgen_prefix.change(lambda x: params.update({"textgen_prefix": x}), textgen_prefix, None)
|
||||
negative_prompt.change(lambda x: params.update({"negative_prompt": x}), negative_prompt, None)
|
||||
width.change(lambda x: params.update({"width": x}), width, None)
|
||||
height.change(lambda x: params.update({"height": x}), height, None)
|
||||
|
Loading…
Reference in New Issue
Block a user