add support to native presets

pull/348/head
Abdullah Alfaraj 2023-08-24 02:30:21 +03:00
parent ad8f192f51
commit 4ce9d1ff38
10 changed files with 386 additions and 17 deletions

View File

@ -898,7 +898,7 @@
<div class="sp-tab-page" id="sp-lexica-tab-page">
<div class="subTabOptionsContainer"></div>
<div class="flexContainer">
<sp-label slot="label"
>Explore Lexica for prompts and inspiration</sp-label
@ -1128,13 +1128,17 @@
<div id="settingsVAEContainer"></div>
<div id="reactSettingsContainer"></div>
<sp-checkbox checked id="chUseSmartObject"
>Smart Object</sp-checkbox
>
<div>
<sp-checkbox checked id="chUseSmartObject"
>Smart Object</sp-checkbox
>
</div>
<sp-checkbox checked id="chUseOriginalPrompt"
>Restore Original Prompt</sp-checkbox
>
<div>
<sp-checkbox checked id="chUseOriginalPrompt"
>Restore Original Prompt</sp-checkbox
>
</div>
<sp-checkbox checked id="chUseSilentMode" style="display: none"
>Use Silent Mode</sp-checkbox

View File

@ -0,0 +1,56 @@
{
"sd_tab_preset": {
"selected_model": "juggernaut_final.safetensors [88967f03f2]",
"is_lasso_mode": false,
"mode": "inpaint",
"rb_mode": "inpaint",
"batch_size": 1,
"batch_count": 1,
"ratio": 1,
"cfg": 7,
"b_width_height_link": true,
"denoising_strength": 1,
"hr_denoising_strength": 0.7,
"inpaint_full_res": false,
"enable_hr": false,
"image_cfg_scale": 1.5,
"seed": "-1",
"mask_blur": 0,
"mask_expansion": 0,
"inpaint_full_res_padding": 0,
"hr_scale": 2,
"hr_resize_x": 512,
"hr_resize_y": 512,
"hr_second_pass_steps": 0,
"restore_faces": false,
"inpainting_fill": 2,
"hr_upscaler": "",
"selection_mode": "ratio"
},
"controlnet_tab_preset": [
{
"enabled": true,
"module": "inpaint_only",
"model": "control_v11p_sd15_inpaint [ebff9138]",
"weight": 1,
"resize_mode": "Scale to Fit (Inner Fit)",
"lowvram": true,
"processor_res": 512,
"threshold_a": 0,
"threshold_b": 0,
"guidance_start": 0,
"guidance_end": 1,
"guessmode": false,
"control_mode": "Balanced",
"pixel_perfect": true,
"auto_image": true,
"filter_keyword": "Inpaint"
},
{},
{},
{},
{},
{},
{}
]
}

View File

@ -0,0 +1,72 @@
{
"sd_tab_preset": {
"selected_model": "juggernaut_final.safetensors [88967f03f2]",
"is_lasso_mode": false,
"mode": "inpaint",
"rb_mode": "inpaint",
"batch_size": 1,
"batch_count": 1,
"ratio": 1,
"b_width_height_link": true,
"denoising_strength": 1,
"hr_denoising_strength": 0.7,
"inpaint_full_res": false,
"enable_hr": false,
"image_cfg_scale": 1.5,
"seed": "-1",
"mask_blur": 0,
"mask_expansion": 0,
"inpaint_full_res_padding": 0,
"hr_scale": 2,
"hr_resize_x": 512,
"hr_resize_y": 512,
"hr_second_pass_steps": 0,
"restore_faces": false,
"inpainting_fill": 2,
"hr_upscaler": "",
"selection_mode": "ratio"
},
"controlnet_tab_preset": [
{
"enabled": true,
"module": "inpaint_only",
"model": "control_v11p_sd15_inpaint [ebff9138]",
"weight": 1,
"resize_mode": "Scale to Fit (Inner Fit)",
"lowvram": true,
"processor_res": 512,
"threshold_a": 0,
"threshold_b": 0,
"guidance_start": 0,
"guidance_end": 1,
"guessmode": false,
"control_mode": "Balanced",
"pixel_perfect": true,
"auto_image": true,
"filter_keyword": "Inpaint"
},
{
"enabled": true,
"module": "tile_resample",
"model": "control_v11f1e_sd15_tile [a371b31b]",
"weight": 0.4,
"resize_mode": "Scale to Fit (Inner Fit)",
"lowvram": true,
"processor_res": 512,
"threshold_a": 1,
"threshold_b": 0,
"guidance_start": 0,
"guidance_end": 1,
"guessmode": false,
"control_mode": "Balanced",
"pixel_perfect": true,
"auto_image": true,
"filter_keyword": "Tile"
},
{},
{},
{},
{},
{}
]
}

View File

@ -0,0 +1,56 @@
{
"sd_tab_preset": {
"selected_model": "juggernaut_final.safetensors [88967f03f2]",
"is_lasso_mode": false,
"mode": "outpaint",
"rb_mode": "outpaint",
"batch_size": 1,
"batch_count": 1,
"ratio": 1,
"cfg": 7,
"b_width_height_link": true,
"denoising_strength": 1,
"hr_denoising_strength": 0.7,
"inpaint_full_res": false,
"enable_hr": false,
"image_cfg_scale": 1.5,
"seed": "-1",
"mask_blur": 0,
"mask_expansion": 0,
"inpaint_full_res_padding": 0,
"hr_scale": 2,
"hr_resize_x": 512,
"hr_resize_y": 512,
"hr_second_pass_steps": 0,
"restore_faces": false,
"inpainting_fill": 3,
"hr_upscaler": "",
"selection_mode": "ratio"
},
"controlnet_tab_preset": [
{
"enabled": true,
"module": "inpaint_only",
"model": "control_v11p_sd15_inpaint [ebff9138]",
"weight": 1,
"resize_mode": "Scale to Fit (Inner Fit)",
"lowvram": true,
"processor_res": 512,
"threshold_a": 0,
"threshold_b": 0,
"guidance_start": 0,
"guidance_end": 1,
"guessmode": false,
"control_mode": "Balanced",
"pixel_perfect": true,
"auto_image": true,
"filter_keyword": "Inpaint"
},
{},
{},
{},
{},
{},
{}
]
}

43
presets/default.json Normal file
View File

@ -0,0 +1,43 @@
{
"sd_tab_preset": {
"selected_model": "v1-5-pruned-emaonly.ckpt [cc6cb27103]",
"is_lasso_mode": false,
"mode": "txt2img",
"rb_mode": "txt2img",
"batch_size": 1,
"batch_count": 1,
"steps": 20,
"width": 512,
"height": 512,
"ratio": 1,
"cfg": 7,
"b_width_height_link": true,
"denoising_strength": 0.7,
"hr_denoising_strength": 0.7,
"inpaint_full_res": false,
"enable_hr": false,
"sampler_name": "Euler a",
"image_cfg_scale": 1.5,
"seed": "-1",
"mask_blur": 0,
"mask_expansion": 0,
"inpaint_full_res_padding": 0,
"hr_scale": 2,
"hr_resize_x": 512,
"hr_resize_y": 512,
"hr_second_pass_steps": 0,
"restore_faces": false,
"inpainting_fill": 0,
"hr_upscaler": "",
"selection_mode": "ratio"
},
"controlnet_tab_preset": [
{},
{},
{},
{},
{},
{},
{}
]
}

42
presets/img2img.json Normal file
View File

@ -0,0 +1,42 @@
{
"sd_tab_preset": {
"is_lasso_mode": false,
"mode": "img2img",
"rb_mode": "img2img",
"batch_size": 1,
"batch_count": 1,
"steps": 20,
"width": 512,
"height": 512,
"ratio": 1,
"cfg": 7,
"b_width_height_link": true,
"denoising_strength": 0.6,
"hr_denoising_strength": 0.7,
"inpaint_full_res": false,
"enable_hr": false,
"sampler_name": "Euler a",
"image_cfg_scale": 1.5,
"seed": "-1",
"mask_blur": 0,
"mask_expansion": 10,
"inpaint_full_res_padding": 0,
"hr_scale": 2,
"hr_resize_x": 512,
"hr_resize_y": 512,
"hr_second_pass_steps": 0,
"restore_faces": false,
"inpainting_fill": 2,
"hr_upscaler": "",
"selection_mode": "ratio"
},
"controlnet_tab_preset": [
{},
{},
{},
{},
{},
{},
{}
]
}

42
presets/inpaint.json Normal file
View File

@ -0,0 +1,42 @@
{
"sd_tab_preset": {
"is_lasso_mode": false,
"mode": "inpaint",
"rb_mode": "inpaint",
"batch_size": 1,
"batch_count": 1,
"steps": 20,
"width": 512,
"height": 512,
"ratio": 1,
"cfg": 7,
"b_width_height_link": true,
"denoising_strength": 0.7,
"hr_denoising_strength": 0.7,
"inpaint_full_res": false,
"enable_hr": false,
"sampler_name": "Euler a",
"image_cfg_scale": 1.5,
"seed": "-1",
"mask_blur": 0,
"mask_expansion": 0,
"inpaint_full_res_padding": 0,
"hr_scale": 2,
"hr_resize_x": 512,
"hr_resize_y": 512,
"hr_second_pass_steps": 0,
"restore_faces": false,
"inpainting_fill": 1,
"hr_upscaler": "",
"selection_mode": "ratio"
},
"controlnet_tab_preset": [
{},
{},
{},
{},
{},
{},
{}
]
}

31
presets/outpaint.json Normal file
View File

@ -0,0 +1,31 @@
{
"sd_tab_preset": {
"is_lasso_mode": false,
"mode": "outpaint",
"rb_mode": "outpaint",
"batch_size": 1,
"batch_count": 1,
"steps": 20,
"ratio": 1,
"cfg": 7,
"b_width_height_link": true,
"denoising_strength": 0.92,
"hr_denoising_strength": 0.7,
"inpaint_full_res": false,
"enable_hr": false,
"sampler_name": "Euler a",
"image_cfg_scale": 1.5,
"mask_blur": 0,
"mask_expansion": 10,
"inpaint_full_res_padding": 0,
"hr_scale": 2,
"hr_resize_x": 512,
"hr_resize_y": 512,
"hr_second_pass_steps": 0,
"restore_faces": false,
"inpainting_fill": 2,
"hr_upscaler": "",
"selection_mode": "ratio"
},
"controlnet_tab_preset": []
}

View File

@ -574,13 +574,15 @@ class SDTab extends React.Component<{}> {
<SpMenu
size="s"
title="Custom Presets"
items={Object.keys(
preset_store.data.custom_presets
)}
items={Object.keys({
...helper_store.data.native_presets,
...preset_store.data.custom_presets,
})}
label_item="Select a Custom Preset"
selected_index={Object.keys(
preset_store.data.custom_presets
).indexOf(
selected_index={Object.keys({
...helper_store.data.native_presets,
...preset_store.data.custom_presets,
}).indexOf(
preset_store.data
.selected_sd_preset_name
)}
@ -588,10 +590,10 @@ class SDTab extends React.Component<{}> {
console.log('value:', value)
preset_store.data.selected_sd_preset_name =
value.item
preset_store.data.selected_sd_preset =
preset_store.data.custom_presets[
value.item
]
preset_store.data.selected_sd_preset = {
...helper_store.data.native_presets,
...preset_store.data.custom_presets,
}[value.item]
console.log(
'preset_store.data.selected_sd_preset:',
preset_store.data.selected_sd_preset

View File

@ -25,6 +25,9 @@ import { setUnitData } from '../controlnet/entry'
import { controlNetUnitData } from '../controlnet/store'
import { presetToStore } from '../util/ts/io'
import { refreshExtraUpscalers } from '../extra_page/extra_page'
import { readdirSync, readFileSync } from 'fs'
declare let g_models: any[]
declare let g_automatic_status: any
declare let g_sd_options_obj: any
@ -175,6 +178,7 @@ export const helper_store = new AStore({
hr_upscaler_list: [] as string[],
previous_width: 512,
previous_height: 512,
native_presets: {},
})
export async function refreshModels() {
let b_result = false
@ -328,6 +332,21 @@ export async function initSamplers() {
return bStatus
}
export function loadNativePreset() {
const json_container: { [key: string]: any } = {}
const dir = 'plugin:/presets' // specify the directory containing the .json files
readdirSync(dir).forEach((file) => {
if (file.endsWith('.json')) {
const fileContent = readFileSync(`${dir}/${file}`, 'utf8')
const fileNameWithoutExtension = file.slice(0, -5)
json_container[fileNameWithoutExtension] = JSON.parse(fileContent)
}
})
console.log(json_container)
return json_container
}
export async function refreshUI() {
try {
const b_proxy_server_status = await updateVersionUI()
@ -375,6 +394,8 @@ export async function refreshUI() {
g_controlnet_max_models = await control_net.requestControlNetMaxUnits()
await control_net.initializeControlNetTab(g_controlnet_max_models)
await main.populateVAE()
helper_store.data.native_presets = loadNativePreset()
} catch (e) {
console.warn(e)
}