extremely ugly WIP implementation of img2img inpaint fill modes

This commit is contained in:
tim h 2022-12-31 13:31:31 -06:00
parent 6e8713a2e2
commit 370994a5d2
3 changed files with 47 additions and 3 deletions

View file

@ -323,7 +323,7 @@
<script src="js/lib/layers.js?v=a1f8aea" type="text/javascript"></script> <script src="js/lib/layers.js?v=a1f8aea" type="text/javascript"></script>
<script src="js/lib/commands.js?v=00464cb" type="text/javascript"></script> <script src="js/lib/commands.js?v=00464cb" type="text/javascript"></script>
<script src="js/lib/toolbar.js?v=8a08072" type="text/javascript"></script> <script src="js/lib/toolbar.js?v=26b01aa" type="text/javascript"></script>
<script src="js/lib/ui.js?v=76ede2b" type="text/javascript"></script> <script src="js/lib/ui.js?v=76ede2b" type="text/javascript"></script>
<script <script
@ -349,7 +349,7 @@
src="js/ui/tool/generic.js?v=2bcd36d" src="js/ui/tool/generic.js?v=2bcd36d"
type="text/javascript"></script> type="text/javascript"></script>
<script src="js/ui/tool/dream.js?v=1de8e4e" type="text/javascript"></script> <script src="js/ui/tool/dream.js?v=fbc7f1d" type="text/javascript"></script>
<script <script
src="js/ui/tool/maskbrush.js?v=1e8a893" src="js/ui/tool/maskbrush.js?v=1e8a893"
type="text/javascript"></script> type="text/javascript"></script>

View file

@ -188,4 +188,30 @@ const _toolbar_input = {
}, },
}; };
}, },
selectlist: (
state,
dataKey,
text,
options = {value, text},
defaultOptionValue,
cb = null
) => {
const selectlist = document.createElement("select");
Object.entries(options).forEach((opt) => {
var option = document.createElement("option");
option.value = opt[0];
option.text = opt[1];
selectlist.options.add(option);
});
selectlist.selectedIndex = defaultOptionValue;
selectlist.onchange = () => {
state[dataKey] = selectlist.selectedIndex;
cb && cb();
};
const label = document.createElement("label");
label.appendChild(selectlist);
label.appendChild(new Text(text));
return {selectlist, label};
},
}; };

View file

@ -932,7 +932,7 @@ const dream_img2img_callback = (bb, resolution, state) => {
request.height = resolution.h; request.height = resolution.h;
request.denoising_strength = state.denoisingStrength; request.denoising_strength = state.denoisingStrength;
request.inpainting_fill = 1; // For img2img use original request.inpainting_fill = state.inpainting_fill; //let's see how this works //1; // For img2img use original
// Load prompt (maybe we should add some events so we don't have to do this) // Load prompt (maybe we should add some events so we don't have to do this)
request.prompt = document.getElementById("prompt").value; request.prompt = document.getElementById("prompt").value;
@ -2018,6 +2018,23 @@ const img2imgTool = () =>
textStep: 1, textStep: 1,
} }
).slider; ).slider;
// inpaint fill type select list
state.ctxmenu.inpaintTypeSelect = _toolbar_input.selectlist(
state,
"inpainting_fill",
"Inpaint Type",
{
0: "fill",
1: "original (recommended)",
2: "latent noise",
3: "latent nothing",
},
1, // USE ORIGINAL FOR IMG2IMG OR ELSE but we still give you the option because we love you
() => {
stableDiffusionData.inpainting_fill = state.inpainting_fill;
}
).label;
} }
menu.appendChild(state.ctxmenu.cursorSizeSlider); menu.appendChild(state.ctxmenu.cursorSizeSlider);
@ -2035,6 +2052,7 @@ const img2imgTool = () =>
menu.appendChild(state.ctxmenu.denoisingStrengthSlider); menu.appendChild(state.ctxmenu.denoisingStrengthSlider);
menu.appendChild(state.ctxmenu.borderMaskGradientCheckbox); menu.appendChild(state.ctxmenu.borderMaskGradientCheckbox);
menu.appendChild(state.ctxmenu.borderMaskSlider); menu.appendChild(state.ctxmenu.borderMaskSlider);
menu.appendChild(state.ctxmenu.inpaintTypeSelect);
}, },
shortcut: "I", shortcut: "I",
} }