implement apply style

This commit is contained in:
Vladimir Mandic
2023-10-12 11:00:27 -04:00
parent 59b51cddf2
commit e2e6648bdb
7 changed files with 14 additions and 7 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ max-locals=99
max-parents=99
max-public-methods=99
max-returns=99
max-statements=99
max-statements=199
min-public-methods=1
[EXCEPTIONS]
+1
View File
@@ -24,6 +24,7 @@ Stuff to be added, in no particular order...
- Backends:
- PyTorch / XLA
- Diffusers / ONNX
- ScaleCrafter <https://github.com/YingqingHe/ScaleCrafter>
- New Minor
- Prompt padding for positive/negative
- New Major
+6 -1
View File
@@ -20,7 +20,10 @@ const getENActiveTab = () => gradioApp().getElementById('tab_txt2img').style.dis
const getENActivePage = () => {
const tabname = getENActiveTab();
const page = gradioApp().querySelector(`#${tabname}_extra_networks > .tabs > .tab-nav > .selected`);
return page ? page.innerText : '';
const pageName = page ? page.innerText : '';
const btnApply = gradioApp().getElementById(`${tabname}_extra_apply`);
if (btnApply) btnApply.style.display = pageName === 'Style' ? 'inline-flex' : 'none';
return pageName;
};
const setENState = (state) => {
@@ -193,10 +196,12 @@ function setupExtraNetworksForTab(tabname) {
const btnSave = gradioApp().getElementById(`${tabname}_extra_save`);
const btnClose = gradioApp().getElementById(`${tabname}_extra_close`);
const btnModel = gradioApp().getElementById(`${tabname}_extra_model`);
const btnApply = gradioApp().getElementById(`${tabname}_extra_apply`);
const buttons = document.createElement('span');
buttons.classList.add('buttons');
if (btnRefresh) buttons.appendChild(btnRefresh);
if (btnModel) buttons.appendChild(btnModel);
if (btnApply) buttons.appendChild(btnApply);
if (btnScan) buttons.appendChild(btnScan);
if (btnSave) buttons.appendChild(btnSave);
if (btnClose) buttons.appendChild(btnClose);
-2
View File
@@ -5,14 +5,12 @@ let nvmlTable = null;
async function updateNVML() {
try {
const res = await fetch('/sdapi/v1/nvml');
console.log('HERE1', res);
if (!res.ok) {
clearInterval(nvmlInterval);
nvmlEl.style.display = 'none';
return;
}
const data = await res.json();
console.log('HERE2', data);
if (!data) {
clearInterval(nvmlInterval);
nvmlEl.style.display = 'none';
+1
View File
@@ -181,6 +181,7 @@ table.settings-value-table td { padding: 0.4em; border: 1px solid #ccc; max-widt
.extra-networks .description { flex: 3; }
.extra-networks .tab-nav > button { margin-right: 0; height: 24px; padding: 2px 4px 2px 4px; }
.extra-networks .buttons { position: absolute; right: 0; margin: -4px; background: var(--background-color); }
.extra-networks .buttons>button { height: 1.2em; margin-top: var(--spacing-md); }
.extra-networks .custom-button { width: 120px; width: 100%; background: none; justify-content: left; text-align: left; padding: 2px 8px 2px 16px; text-indent: -8px; box-shadow: none; line-break: auto; }
.extra-networks .custom-button:hover { background: var(--button-primary-background-fill) }
.extra-networks-tab { padding: 0 !important; }
+1 -1
View File
@@ -62,7 +62,7 @@ class CFGDenoiser(torch.nn.Module):
@property
def inner_model(self):
raise NotImplementedError()
raise NotImplementedError
def combine_denoised(self, x_out, conds_list, uncond, cond_scale):
denoised_uncond = x_out[-uncond.shape[0]:]
+4 -2
View File
@@ -261,8 +261,10 @@ def create_toprow(is_img2img):
negative_token_button = gr.Button(visible=False, elem_id=f"{id_part}_negative_token_button")
with gr.Row(elem_id=f"{id_part}_styles_row"):
prompt_styles = gr.Dropdown(label="Styles", elem_id=f"{id_part}_styles", choices=[style.name for style in modules.shared.prompt_styles.styles.values()], value=[], multiselect=True)
prompt_styles_btn = gr.Button('Apply', elem_id=f"{id_part}_styles_select", visible=False)
prompt_styles_btn.click(_js="applyStyles", fn=parse_style, inputs=[prompt_styles], outputs=[prompt_styles])
prompt_styles_btn_select = gr.Button('Select', elem_id=f"{id_part}_styles_select", visible=False)
prompt_styles_btn_select.click(_js="applyStyles", fn=parse_style, inputs=[prompt_styles], outputs=[prompt_styles])
prompt_styles_btn_apply = ToolButton(symbols.apply, elem_id=f"{id_part}_extra_apply", visible=False)
prompt_styles_btn_apply.click(fn=apply_styles, inputs=[prompt, negative_prompt, prompt_styles], outputs=[prompt, negative_prompt, prompt_styles])
return prompt, prompt_styles, negative_prompt, submit, button_interrogate, button_deepbooru, button_paste, button_extra, token_counter, token_button, negative_token_counter, negative_token_button