mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-21 23:57:58 +01:00
SD_api_pictures: Modefix, +hires options, UI layout change (#1400)
This commit is contained in:
parent
2dca8bb25e
commit
143e88694d
26
css/main.css
26
css/main.css
@ -111,3 +111,29 @@ button {
|
||||
.small-button {
|
||||
max-width: 171px;
|
||||
}
|
||||
|
||||
/* Align the elements for SD_api_picture extension */
|
||||
.SDAP #sampler_box {
|
||||
padding-top: var(--spacing-sm);
|
||||
padding-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.SDAP #seed_box,
|
||||
.SDAP #cfg_box {
|
||||
padding-top: var(--spacing-md);
|
||||
}
|
||||
|
||||
.SDAP #sampler_box span,
|
||||
.SDAP #seed_box span,
|
||||
.SDAP #cfg_box span{
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.SDAP svg.dropdown-arrow {
|
||||
flex-shrink: 0 !important;
|
||||
margin: 0px !important;
|
||||
}
|
||||
|
||||
.SDAP .hires_opts input[type="number"] {
|
||||
width: 6em !important;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
## Description:
|
||||
TL;DR: Lets the bot answer you with a picture!
|
||||
|
||||
Stable Diffusion API pictures for TextGen, v.1.1.1
|
||||
Stable Diffusion API pictures for TextGen, v.1.2.0
|
||||
An extension to [oobabooga's textgen-webui](https://github.com/oobabooga/text-generation-webui) allowing you to receive pics generated by [Automatic1111's SD-WebUI API](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
|
||||
|
||||
<details>
|
||||
|
@ -25,7 +25,11 @@ params = {
|
||||
'negative_prompt': '(worst quality, low quality:1.3)',
|
||||
'width': 512,
|
||||
'height': 512,
|
||||
'denoising_strength': 0.61,
|
||||
'restore_faces': False,
|
||||
'enable_hr': False,
|
||||
'hr_upscaler': 'ESRGAN_4x',
|
||||
'hr_scale': '1.0',
|
||||
'seed': -1,
|
||||
'sampler_name': 'DDIM',
|
||||
'steps': 32,
|
||||
@ -74,7 +78,6 @@ SD_models = ['NeverEndingDream'] # TODO: get with http://{address}}/sdapi/v1/sd
|
||||
streaming_state = shared.args.no_stream # remember if chat streaming was enabled
|
||||
picture_response = False # specifies if the next model response should appear as a picture
|
||||
|
||||
|
||||
def remove_surrounded_chars(string):
|
||||
# this expression matches to 'as few symbols as possible (0 upwards) between any asterisks' OR
|
||||
# 'as few symbols as possible (0 upwards) between an asterisk and the end of the string'
|
||||
@ -123,11 +126,16 @@ def get_SD_pictures(description):
|
||||
"prompt": params['prompt_prefix'] + description,
|
||||
"seed": params['seed'],
|
||||
"sampler_name": params['sampler_name'],
|
||||
"enable_hr": params['enable_hr'],
|
||||
"hr_scale": params['hr_scale'],
|
||||
"hr_upscaler": params['hr_upscaler'],
|
||||
"denoising_strength": params['denoising_strength'],
|
||||
"steps": params['steps'],
|
||||
"cfg_scale": params['cfg_scale'],
|
||||
"width": params['width'],
|
||||
"height": params['height'],
|
||||
"restore_faces": params['restore_faces'],
|
||||
"override_settings_restore_afterwards": True,
|
||||
"negative_prompt": params['negative_prompt']
|
||||
}
|
||||
|
||||
@ -246,15 +254,15 @@ def SD_api_address_update(address):
|
||||
|
||||
return gr.Textbox.update(label=msg)
|
||||
|
||||
|
||||
def ui():
|
||||
|
||||
# Gradio elements
|
||||
# gr.Markdown('### Stable Diffusion API Pictures') # Currently the name of extension is shown as the title
|
||||
with gr.Accordion("Parameters", open=True):
|
||||
with gr.Accordion("Parameters", open=True, elem_classes="SDAP"):
|
||||
with gr.Row():
|
||||
address = gr.Textbox(placeholder=params['address'], value=params['address'], label='Auto1111\'s WebUI address')
|
||||
mode = gr.Dropdown(["Manual", "Immersive/Interactive", "Picturebook/Adventure"], value="Manual", label="Mode of operation", type="index")
|
||||
modes_list = ["Manual", "Immersive/Interactive", "Picturebook/Adventure"]
|
||||
mode = gr.Dropdown(modes_list, value=modes_list[params['mode']], label="Mode of operation", type="index")
|
||||
with gr.Column(scale=1, min_width=300):
|
||||
manage_VRAM = gr.Checkbox(value=params['manage_VRAM'], label='Manage VRAM')
|
||||
save_img = gr.Checkbox(value=params['save_img'], label='Keep original images and use them in chat')
|
||||
@ -264,17 +272,25 @@ 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)')
|
||||
negative_prompt = gr.Textbox(placeholder=params['negative_prompt'], value=params['negative_prompt'], label='Negative Prompt')
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
negative_prompt = gr.Textbox(placeholder=params['negative_prompt'], value=params['negative_prompt'], label='Negative Prompt')
|
||||
sampler_name = gr.Textbox(placeholder=params['sampler_name'], value=params['sampler_name'], label='Sampler')
|
||||
with gr.Column():
|
||||
width = gr.Slider(256, 768, value=params['width'], step=64, label='Width')
|
||||
height = gr.Slider(256, 768, value=params['height'], step=64, label='Height')
|
||||
with gr.Column():
|
||||
sampler_name = gr.Textbox(placeholder=params['sampler_name'], value=params['sampler_name'], label='Sampling method', elem_id="sampler_box")
|
||||
steps = gr.Slider(1, 150, value=params['steps'], step=1, label="Sampling steps")
|
||||
with gr.Row():
|
||||
steps = gr.Number(label="Steps:", value=params['steps'])
|
||||
seed = gr.Number(label="Seed:", value=params['seed'])
|
||||
cfg_scale = gr.Number(label="CFG Scale:", value=params['cfg_scale'])
|
||||
seed = gr.Number(label="Seed", value=params['seed'], elem_id="seed_box")
|
||||
cfg_scale = gr.Number(label="CFG Scale", value=params['cfg_scale'], elem_id="cfg_box")
|
||||
with gr.Column() as hr_options:
|
||||
restore_faces = gr.Checkbox(value=params['restore_faces'], label='Restore faces')
|
||||
enable_hr = gr.Checkbox(value=params['enable_hr'], label='Hires. fix')
|
||||
with gr.Row(visible=params['enable_hr'], elem_classes="hires_opts") as hr_options:
|
||||
hr_scale = gr.Slider(1, 4, value=params['hr_scale'], step=0.1, label='Upscale by')
|
||||
denoising_strength = gr.Slider(0, 1, value=params['denoising_strength'], step=0.01, label='Denoising strength')
|
||||
hr_upscaler = gr.Textbox(placeholder=params['hr_upscaler'], value=params['hr_upscaler'], label='Upscaler')
|
||||
|
||||
|
||||
# Event functions to update the parameters in the backend
|
||||
address.change(lambda x: params.update({"address": filter_address(x)}), address, None)
|
||||
@ -289,6 +305,12 @@ def ui():
|
||||
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)
|
||||
hr_scale.change(lambda x: params.update({"hr_scale": x}), hr_scale, None)
|
||||
denoising_strength.change(lambda x: params.update({"denoising_strength": x}), denoising_strength, None)
|
||||
restore_faces.change(lambda x: params.update({"restore_faces": x}), restore_faces, None)
|
||||
hr_upscaler.change(lambda x: params.update({"hr_upscaler": x}), hr_upscaler, None)
|
||||
enable_hr.change(lambda x: params.update({"enable_hr": x}), enable_hr, None)
|
||||
enable_hr.change(lambda x: hr_options.update(visible=params["enable_hr"]), enable_hr, hr_options)
|
||||
|
||||
sampler_name.change(lambda x: params.update({"sampler_name": x}), sampler_name, None)
|
||||
steps.change(lambda x: params.update({"steps": x}), steps, None)
|
||||
|
Loading…
Reference in New Issue
Block a user