Skip to content

Commit ae8f81a

Browse files
author
legionfu
committed
* 缺失LoRA模型提示
* 插件增加Core和ALL两种运行模式
1 parent 8583534 commit ae8f81a

File tree

7 files changed

+249
-53
lines changed

7 files changed

+249
-53
lines changed

ChangeLog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
## 2.1.2
22

3+
### Features:
4+
* 缺失LoRA模型提示。
5+
* 插件增加Core和ALL两种运行模式,Core模式仅支持WebUI的基本参数+ControlNet参数。All模式则会尽可能多的支持页面上的参数,但是缺点是有概率导致UI卡住,无限转圈。
6+
7+
### Bug Fixes:
8+
* 修复了一些已知的问题。
9+
* 修复了一些img2img模式丢失的参数。
10+
11+
12+
## 2.1.2
13+
314
### Features:
415
* UI组件增加elem_id。
516
* flow文件导出时,支持自定义名称。

javascript/state.core.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ state.core = (function () {
3939
'resize_mode': 'resize_mode',
4040
'setting_inpainting_mask_weight': 'setting_inpainting_mask_weight',
4141
'setting_CLIP_stop_at_last_layers': 'setting_CLIP_stop_at_last_layers',
42-
'setting_eta_noise_seed_delta': 'setting_eta_noise_seed_delta'
42+
'setting_eta_noise_seed_delta': 'setting_eta_noise_seed_delta',
43+
'img2img_mask_blur': 'img2img_mask_blur',
44+
'img2img_mask_mode': 'img2img_mask_mode',
45+
'img2img_inpainting_fill': 'img2img_inpainting_fill',
46+
'img2img_inpaint_full_res_padding': 'img2img_inpaint_full_res_padding',
47+
'img2img_inpaint_full_res': 'img2img_inpaint_full_res',
48+
'img2img_mask_alpha': 'img2img_mask_alpha'
4349
//'generation_info_txt2img': 'generation_info_txt2img' // 可能因为是visible=false 所以触发不了onchange事件?
4450
};
4551

@@ -143,6 +149,7 @@ state.core = (function () {
143149

144150
let img_elem_keys=[];
145151
let ext_list=[];
152+
let flow_save_mode = "Core"
146153

147154
function get_imgs_elem_key(){
148155

@@ -173,6 +180,13 @@ state.core = (function () {
173180
.then(response => response.json())
174181
.then(config => {
175182
try {
183+
184+
try{
185+
flow_save_mode = config['lightdiffusionflow-mode']
186+
}catch (error) {
187+
flow_save_mode = "Core"
188+
}
189+
176190
store = new state.Store();
177191
store.clearAll();
178192
load(config);
@@ -469,7 +483,7 @@ state.core = (function () {
469483
// }
470484

471485
for (const [name, obj] of Object.entries(state.extensions)) {
472-
obj.init();
486+
obj.init(flow_save_mode == "Core");
473487
}
474488

475489
}
@@ -546,6 +560,12 @@ state.core = (function () {
546560
.then(config => {
547561
try {
548562
config.hasSetting = hasSetting
563+
564+
try{
565+
flow_save_mode = config['lightdiffusionflow-mode']
566+
}catch (error) {
567+
flow_save_mode = "Core"
568+
}
549569
//console.log(config)
550570
//restoreTabs(config); // 恢复到最后点击的tab页面
551571
load(config);

javascript/state.ext.general.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function general_ext_main(tab){
411411
return res
412412
}
413413

414-
function init() {
414+
function init(core_mode = true) {
415415
console.log(`------------${cur_tab_name}----init-------`)
416416

417417
let container = gradioApp().getElementById(cur_tab_name+'_script_container'); // main container
@@ -446,6 +446,9 @@ function general_ext_main(tab){
446446
if(reg.test(title)){title = RegExp.$1} // 匹配 xxx v0.0.0 格式的标题,把后半部分的版本号去掉
447447

448448
if(title == "ControlNet"){title = "Control Net"} // 兼容旧命名
449+
else{
450+
if(core_mode){continue}
451+
}
449452

450453
let ext_name = title.replace(" ","-").toLowerCase()
451454
console.log(ext_name)

javascript/state.utils.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,42 @@ state.utils = {
88
//console.log(state.extensions)
99
// const button = gradioApp().getElementById("lightdiffusionflow_set_elements");
1010
// button.click();
11+
json_obj = {
12+
"state-ext-control-net-txt2img_0-enable": "true",
13+
"state-ext-control-net-txt2img_0-canny-high-threshold": "255",
14+
"state-ext-control-net-txt2img_3-enable": "true",
15+
"state-ext-control-net-txt2img_0-starting-control-step": "1",
16+
"state-ext-control-net-txt2img_0-canny-low-threshold": "255",
17+
"state-ext-control-net-txt2img_0-control-weight": "2",
18+
"state-ext-control-net-txt2img_3-control-type": "OpenPose",
19+
"state-ext-control-net-txt2img_0-control-mode": "ControlNet is more important",
20+
"state-ext-control-net-txt2img_0-control-type": "Canny",
21+
"state-setting_sd_model_checkpoint": "majicmixRealistic_betterV2V25.safetensors [d7e2ac2f4a]",
22+
"state-ext-control-net-txt2img_0-preprocessor-resolution": "2048",
23+
"state-ext-control-net-txt2img-tab": "ControlNet Unit 3 ",
24+
"state-ext-control-net-txt2img_1-enable": "false",
25+
"state-tab": "txt2img ",
26+
"state-ext-control-net-txt2img-toggled": "true",
27+
"txt2img_controlnet_ControlNet-1_input_image": "data:image",
28+
"state-ext-control-net-txt2img_0-preprocessor": "canny",
29+
"state-ext-control-net-txt2img_0-model": "control_v11p_sd15_canny [d14c016b]",
30+
"state-ext-control-net-txt2img_3-preprocessor": "openpose_full",
31+
"state-ext-control-net-txt2img_3-model": "control_v11p_sd15_openpose [cab727d4]"
32+
}
33+
34+
console.log(json_obj["state-ext-control-net-txt2img_0-enable"])
35+
console.log(json_obj["state-ext-control-net-txt2img_0-enabl1e"])
36+
37+
},
38+
39+
fix_old_json_error: function fix_old_json_error(json_obj){
40+
41+
cn_index = 1
42+
for (let cn_index=1; cn_index < 10; cn_index++){
43+
44+
}
45+
46+
return json_obj
1147
},
1248

1349
target_is_newer_version: function(cur_version, target_version){

scripts/lightdiffusionflow_config.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
PNGINFO_2_LIGHTDIFFUSIONFLOW = {}
44
PNGINFO_CN_2_LIGHTDIFFUSIONFLOW = {}
55
Image_Components_Key = {}
6+
LoRAs_In_Use = "loras_in_use"
67

78
class OutputPrompt_English:
89

@@ -33,11 +34,22 @@ def missing_extensions(ext_list:[]):
3334
error_str+="<b style='color:Orange;'>The above Extension Missing Reminder is for reference only. Please determine the necessary plugins based on your actual needs and specific conditions.</b></p> "
3435
return error_str
3536

37+
def missing_loras(loras_list:[]):
38+
error_str = "Note: <b style='color:Orange;'>Found missing LoRAs.</b></p>"
39+
for lora in loras_list:
40+
error_str+="<p>- <b style='color:Orange;'>"+lora+"</b></p> "
41+
return error_str
42+
3643
def click_to_download(file_name, file_url):
3744
return f'''<p style="color:Orange;">Click to download \
3845
<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {file_name} </a>
3946
'''
4047

48+
def note_for_save_mode():
49+
return "Core mode only supports basic parameters for Text-to-Image and Image-to-Image, along with ControlNet parameters. \
50+
The All mode, on the other hand, aims to support as many parameters as possible on the page, \
51+
but the downside is that it may occasionally cause the UI to freeze with an infinite loading circle."
52+
4153
class OutputPrompt_Chinese:
4254

4355
def startimport():
@@ -70,6 +82,12 @@ def missing_extensions(ext_list:[]):
7082
error_str+="<b style='color:Orange;'>以上插件缺失提示仅供参考,请注意辨别实际情况下您所需要安装的插件。</b></p> "
7183
return error_str
7284

85+
def missing_loras(loras_list:[]):
86+
error_str = "注意, <b style='color:Orange;'>发现缺失的LoRA模型:</b></p>"
87+
for lora in loras_list:
88+
error_str+="<p>- <b style='color:Orange;'>"+lora+"</b></p> "
89+
return error_str
90+
7391
def click_to_download(file_name, file_url):
7492
name = file_name
7593
if(name == "ControlNet Models"):
@@ -82,12 +100,17 @@ def click_to_download(file_name, file_url):
82100
<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {name} </a>
83101
'''
84102

103+
def note_for_save_mode():
104+
return "Core模式仅支持文生图和图生图的基本参数+ControlNet参数。All模式则会尽可能多的支持页面上的参数,但是缺点是有概率导致UI卡住,无限转圈。"
105+
106+
85107
OutputPrompt = OutputPrompt_English
108+
Flow_Save_mode = "Core"
86109

87110
# 改成函数调用,修改配置之后能及时刷新
88111
def init():
89112
global PNGINFO_2_LIGHTDIFFUSIONFLOW,PNGINFO_CN_2_LIGHTDIFFUSIONFLOW
90-
global OutputPrompt,Image_Components_Key
113+
global OutputPrompt,Flow_Save_mode,Image_Components_Key
91114
# PNG Info的功能除了主要的选项以外其他的都靠第三方插件的主动支持,后续再考虑能否有优化的办法
92115
#print(parameters_copypaste.paste_fields)
93116
PNGINFO_2_LIGHTDIFFUSIONFLOW = {
@@ -133,40 +156,46 @@ def init():
133156
json_str = f.read()
134157
webui_settings = json.loads(json_str)
135158

136-
successed = False
159+
# 保存模式
160+
try:
161+
Flow_Save_mode = webui_settings["lightdiffusionflow-mode"]
162+
except:
163+
Flow_Save_mode = "Core"
164+
165+
language_successed = False
137166
auto_language = False
138167
try:
139168
# 优先读取自己的设置
140169
if(webui_settings['lightdiffusionflow-language'] == "default"):
141170
auto_language = True
142171
elif(webui_settings['lightdiffusionflow-language'] == "english"):
143172
OutputPrompt = OutputPrompt_English
144-
successed = True
173+
language_successed = True
145174
else:
146175
OutputPrompt = OutputPrompt_Chinese
147-
successed = True
176+
language_successed = True
148177
except:
149178
OutputPrompt = OutputPrompt_English
150179

151180
# 如果是default就读取其他设置配合
152-
if(auto_language and not successed):
181+
if(auto_language and not language_successed):
153182
# 自带的本地化文件
154183
localization_files = ["zh_CN", "zh-Hans (Stable) [vladmandic]", "zh-Hans (Stable)",
155184
"zh-Hans (Testing) [vladmandic]", "zh-Hans (Testing)","chinese-all-1024","chinese-english-1024"]
156185
try:
157186
# 如果用户使用了中文汉化文件,插件也默认显示中文
158187
localization_files.index(webui_settings["localization"])
159188
OutputPrompt = OutputPrompt_Chinese
160-
successed = True
189+
language_successed = True
161190
except:
162191
pass
163192

164193
# 第三方翻译插件bilingual-localization
165-
if(not successed):
194+
if(not language_successed):
166195
try:
167196
if(webui_settings["bilingual_localization_enabled"] and webui_settings["bilingual_localization_file"] != "None"):
168197
OutputPrompt = OutputPrompt_Chinese
169-
successed = True
198+
language_successed = True
170199
except:
171200
OutputPrompt = OutputPrompt_English
172201
except:

0 commit comments

Comments
 (0)