Commit 40ff6db5 authored by AUTOMATIC's avatar AUTOMATIC
Browse files

extra networks UI

rework of hypernets: rather than via settings, hypernets are added directly to prompt as <hypernet:name:weight>
parent e33cace2
Loading
Loading
Loading
Loading
+82.5 KiB
Loading image diff...
+11 −0
Original line number Diff line number Diff line
<div class='card' {preview_html} onclick='return cardClicked({prompt}, {allow_negative_prompt})'>
	<div class='actions'>
		<div class='additional'>
			<ul>
				<a href="#" title="replace preview image with currently selected in gallery" onclick='return saveCardPreview(event, {tabname}, {local_preview})'>replace preview</a>
			</ul>
		</div>
		<span class='name'>{name}</span>
	</div>
</div>
+8 −0
Original line number Diff line number Diff line
<div class='nocards'>
<h1>Nothing here. Add some content to the following directories:</h1>

<ul>
{dirs}
</ul>
</div>
+60 −0
Original line number Diff line number Diff line

function setupExtraNetworksForTab(tabname){
    gradioApp().querySelector('#'+tabname+'_extra_tabs').classList.add('extra-networks')

    gradioApp().querySelector('#'+tabname+'_extra_tabs > div').appendChild(gradioApp().getElementById(tabname+'_extra_refresh'))
    gradioApp().querySelector('#'+tabname+'_extra_tabs > div').appendChild(gradioApp().getElementById(tabname+'_extra_close'))
}

var activePromptTextarea = null;
var activePositivePromptTextarea = null;

function setupExtraNetworks(){
    setupExtraNetworksForTab('txt2img')
    setupExtraNetworksForTab('img2img')

    function registerPrompt(id, isNegative){
        var textarea = gradioApp().querySelector("#" + id + " > label > textarea");

        if (activePromptTextarea == null){
            activePromptTextarea = textarea
        }
        if (activePositivePromptTextarea == null && ! isNegative){
            activePositivePromptTextarea = textarea
        }

		textarea.addEventListener("focus", function(){
            activePromptTextarea = textarea;
            if(! isNegative)  activePositivePromptTextarea = textarea;
		});
    }

    registerPrompt('txt2img_prompt')
    registerPrompt('txt2img_neg_prompt', true)
    registerPrompt('img2img_prompt')
    registerPrompt('img2img_neg_prompt', true)
}

onUiLoaded(setupExtraNetworks)

function cardClicked(textToAdd, allowNegativePrompt){
    textarea = allowNegativePrompt ? activePromptTextarea : activePositivePromptTextarea

    textarea.value = textarea.value + " " + textToAdd
    updateInput(textarea)

    return false
}

function saveCardPreview(event, tabname, filename){
    textarea = gradioApp().querySelector("#" + tabname + '_preview_filename  > label > textarea')
    button = gradioApp().getElementById(tabname + '_save_preview')

    textarea.value = filename
    updateInput(textarea)

    button.click()

    event.stopPropagation()
    event.preventDefault()
}
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ titles = {
    "\U0001F5D1": "Clear prompt",
    "\u{1f4cb}": "Apply selected styles to current prompt",
    "\u{1f4d2}": "Paste available values into the field",
    "\u{1f3b4}": "Show extra networks",


    "Inpaint a part of image": "Draw a mask over an image, and the script will regenerate the masked area with content according to prompt",
    "SD upscale": "Upscale image normally, split result into tiles, improve each tile using img2img, merge whole image back",
Loading