mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-21 23:57:58 +01:00
Get SD samplers from API (#2889)
This commit is contained in:
parent
d7a7f7896b
commit
cb029cf65f
@ -12,6 +12,7 @@ from PIL import Image
|
|||||||
|
|
||||||
import modules.shared as shared
|
import modules.shared as shared
|
||||||
from modules.models import reload_model, unload_model
|
from modules.models import reload_model, unload_model
|
||||||
|
from modules.ui import create_refresh_button
|
||||||
|
|
||||||
torch._C._jit_set_profiling_mode(False)
|
torch._C._jit_set_profiling_mode(False)
|
||||||
|
|
||||||
@ -76,7 +77,6 @@ def give_VRAM_priority(actor):
|
|||||||
if params['manage_VRAM']:
|
if params['manage_VRAM']:
|
||||||
give_VRAM_priority('set')
|
give_VRAM_priority('set')
|
||||||
|
|
||||||
samplers = ['DDIM', 'DPM++ 2M Karras'] # TODO: get the availible samplers with http://{address}}/sdapi/v1/samplers
|
|
||||||
SD_models = ['NeverEndingDream'] # TODO: get with http://{address}}/sdapi/v1/sd-models and allow user to select
|
SD_models = ['NeverEndingDream'] # TODO: get with http://{address}}/sdapi/v1/sd-models and allow user to select
|
||||||
|
|
||||||
picture_response = False # specifies if the next model response should appear as a picture
|
picture_response = False # specifies if the next model response should appear as a picture
|
||||||
@ -248,7 +248,6 @@ def filter_address(address):
|
|||||||
|
|
||||||
|
|
||||||
def SD_api_address_update(address):
|
def SD_api_address_update(address):
|
||||||
|
|
||||||
global params
|
global params
|
||||||
|
|
||||||
msg = "✔️ SD API is found on:"
|
msg = "✔️ SD API is found on:"
|
||||||
@ -291,6 +290,17 @@ def load_checkpoint(checkpoint):
|
|||||||
|
|
||||||
requests.post(url=f'{params["address"]}/sdapi/v1/options', json=payload)
|
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')
|
||||||
|
response.raise_for_status()
|
||||||
|
samplers = [x["name"] for x in response.json()]
|
||||||
|
except:
|
||||||
|
samplers = []
|
||||||
|
|
||||||
|
return samplers
|
||||||
|
|
||||||
|
|
||||||
def ui():
|
def ui():
|
||||||
|
|
||||||
# Gradio elements
|
# Gradio elements
|
||||||
@ -317,9 +327,11 @@ def ui():
|
|||||||
with gr.Column():
|
with gr.Column():
|
||||||
width = gr.Slider(256, 768, value=params['width'], step=64, label='Width')
|
width = gr.Slider(256, 768, value=params['width'], step=64, label='Width')
|
||||||
height = gr.Slider(256, 768, value=params['height'], step=64, label='Height')
|
height = gr.Slider(256, 768, value=params['height'], step=64, label='Height')
|
||||||
with gr.Column():
|
with gr.Column(variant="compact", elem_id="sampler_col"):
|
||||||
sampler_name = gr.Textbox(placeholder=params['sampler_name'], value=params['sampler_name'], label='Sampling method', elem_id="sampler_box")
|
with gr.Row(elem_id="sampler_row"):
|
||||||
steps = gr.Slider(1, 150, value=params['steps'], step=1, label="Sampling steps")
|
sampler_name = gr.Dropdown(value=params['sampler_name'], label='Sampling method', elem_id="sampler_box")
|
||||||
|
create_refresh_button(sampler_name, lambda: None, lambda: {'choices': get_samplers()}, 'refresh-button')
|
||||||
|
steps = gr.Slider(1, 150, value=params['steps'], step=1, label="Sampling steps", elem_id="steps_box")
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
seed = gr.Number(label="Seed", value=params['seed'], elem_id="seed_box")
|
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")
|
cfg_scale = gr.Number(label="CFG Scale", value=params['cfg_scale'], elem_id="cfg_box")
|
||||||
|
@ -2,6 +2,32 @@
|
|||||||
.SDAP #sampler_box {
|
.SDAP #sampler_box {
|
||||||
padding-top: var(--spacing-sm);
|
padding-top: var(--spacing-sm);
|
||||||
padding-bottom: var(--spacing-sm);
|
padding-bottom: var(--spacing-sm);
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SDAP #steps_box {
|
||||||
|
border-radius: 0 0 var(--block-radius) var(--block-radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
.SDAP #sampler_col {
|
||||||
|
gap: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SDAP #sampler_row {
|
||||||
|
border-bottom: 0;
|
||||||
|
box-shadow: var(--block-shadow);
|
||||||
|
border-width: var(--block-border-width);
|
||||||
|
border-color: var(--block-border-color);
|
||||||
|
border-radius: var(--block-radius) var(--block-radius) 0 0;
|
||||||
|
background: var(--block-background-fill);
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SDAP #sampler_row .refresh-button {
|
||||||
|
margin-bottom: var(--spacing-sm);
|
||||||
|
margin-right: var(--spacing-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.SDAP #seed_box,
|
.SDAP #seed_box,
|
||||||
@ -11,7 +37,8 @@
|
|||||||
|
|
||||||
.SDAP #sampler_box span,
|
.SDAP #sampler_box span,
|
||||||
.SDAP #seed_box span,
|
.SDAP #seed_box span,
|
||||||
.SDAP #cfg_box span{
|
.SDAP #cfg_box span,
|
||||||
|
.SDAP #steps_box span {
|
||||||
margin-bottom: var(--spacing-sm);
|
margin-bottom: var(--spacing-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user