Skip to content

Commit f8a75c2

Browse files
authored
Merge pull request #18 from Tencent/Branch_dev
Branch dev
2 parents 13a80e7 + 980b174 commit f8a75c2

File tree

8 files changed

+360
-79
lines changed

8 files changed

+360
-79
lines changed

ChangeLog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 2.1.3
2+
3+
### Features:
4+
* 缺失LoRA模型提示。
5+
* 插件增加Core和ALL两种运行模式,Core模式仅支持WebUI的基本参数+ControlNet参数。All模式则会尽可能多的支持页面上的参数,但是缺点是有概率导致UI卡住,无限转圈。
6+
7+
### Bug Fixes:
8+
* 增加了错误参数纠正步骤,处理Controlnet tab保存序号错误的问题。
9+
* 修复了一些已知的问题。
10+
* 修复了一些img2img模式丢失的参数。
11+
12+
113
## 2.1.2
214

315
### Features:

javascript/state.core.js

Lines changed: 24 additions & 3 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);
@@ -612,6 +632,7 @@ state.core = (function () {
612632
for (let key in stored_config){
613633
if(key.indexOf("allow-preview") !== -1 && key.indexOf("ext-control-net") !== -1)
614634
{
635+
console.log("allow-preview改成false")
615636
stored_config[key] = "false"
616637
}
617638
}
@@ -741,7 +762,7 @@ state.core = (function () {
741762
// 缺少的插件
742763
missing_ext_list = []
743764
for (let key in json_obj){
744-
ext_name = key.match(/ext-(\S+)-(txt2img|img2img)/)
765+
ext_name = key.match(/ext-(\S+?)-(txt2img|img2img)/)
745766
console.log(key)
746767
if(ext_name != null){
747768
ext_name = ext_name[1]

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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ state.utils = {
77
testFunction: function testFunction() {
88
//console.log(state.extensions)
99
// const button = gradioApp().getElementById("lightdiffusionflow_set_elements");
10-
// button.click();
10+
// button.click();
1111
},
1212

1313
target_is_newer_version: function(cur_version, target_version){
@@ -182,7 +182,12 @@ state.utils = {
182182
if (element.value === value) {
183183
element.checked = true;
184184
this.triggerEvent(element, event);
185-
} else {
185+
}
186+
else if(element.value == "Scribble/Sketch" && value == "Scribble"){
187+
element.checked = true;
188+
this.triggerEvent(element, event);
189+
}
190+
else {
186191
element.checked = false;
187192
}
188193
break;

scripts/lightdiffusionflow_config.py

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
PNGINFO_2_LIGHTDIFFUSIONFLOW = {}
44
PNGINFO_CN_2_LIGHTDIFFUSIONFLOW = {}
55
Image_Components_Key = {}
6+
LoRAs_In_Use = "loras_in_use"
7+
Flow_Save_mode = "All"
8+
Auto_Fix_Params = True
69

710
class OutputPrompt_English:
811

@@ -27,17 +30,34 @@ def no_option(option_name, value):
2730
The option '<b style='color:Red;'>{value}</b>' was not found!'''
2831

2932
def missing_extensions(ext_list:[]):
30-
error_str = "Note: <b style='color:Orange;'>Found missing extensions.</b></p>"
31-
for ext in ext_list:
32-
error_str+="<p>- <b style='color:Orange;'>"+ext+"</b></p> "
33-
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> "
33+
if(Flow_Save_mode == "Core"):
34+
error_str = "Note: <b style='color:Orange;'>The current flow file contains parameters for other plugins:</b></p>"
35+
for ext in ext_list:
36+
error_str+="<p>- <b style='color:Orange;'>"+ext+"</b></p> "
37+
error_str+="<b style='color:Orange;'>You can switch to 'ALL' mode to load more parameters. (This prompt is for reference only, please choose the plugin mode according to the actual situation.)</b></p> "
38+
else:
39+
error_str = "Note: <b style='color:Orange;'>Found missing extensions.</b></p>"
40+
for ext in ext_list:
41+
error_str+="<p>- <b style='color:Orange;'>"+ext+"</b></p> "
42+
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> "
43+
return error_str
44+
45+
def missing_loras(loras_list:[]):
46+
error_str = "Note: <b style='color:Orange;'>Found missing LoRAs.</b></p>"
47+
for lora in loras_list:
48+
error_str+="<p>- <b style='color:Orange;'>"+lora+"</b></p> "
3449
return error_str
3550

3651
def click_to_download(file_name, file_url):
3752
return f'''<p style="color:Orange;">Click to download \
3853
<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {file_name} </a>
3954
'''
4055

56+
def note_for_save_mode():
57+
return "Core mode only supports basic parameters for Text-to-Image and Image-to-Image, along with ControlNet parameters. \
58+
The All mode, on the other hand, aims to support as many parameters as possible on the page, \
59+
but the downside is that it may occasionally cause the UI to freeze with an infinite loading circle."
60+
4161
class OutputPrompt_Chinese:
4262

4363
def startimport():
@@ -64,10 +84,23 @@ def no_option(option_name, value):
6484
未找到选项'<b style='color:Red;'>{value}</b>'!'''
6585

6686
def missing_extensions(ext_list:[]):
67-
error_str = "注意, <b style='color:Orange;'>发现缺失的插件:</b></p>"
68-
for ext in ext_list:
69-
error_str+="<p>- <b style='color:Orange;'>"+ext+"</b></p> "
70-
error_str+="<b style='color:Orange;'>以上插件缺失提示仅供参考,请注意辨别实际情况下您所需要安装的插件。</b></p> "
87+
global Flow_Save_mode
88+
if(Flow_Save_mode == "Core"):
89+
error_str = "注意, <b style='color:Orange;'>当前flow文件含有其他插件参数:</b></p>"
90+
for ext in ext_list:
91+
error_str+="<p>- <b style='color:Orange;'>"+ext+"</b></p> "
92+
error_str+="<b style='color:Orange;'>可切换至'ALL'模式加载更多参数。(提示仅供参考,请根据实际情况选择插件模式。)</b></p> "
93+
else:
94+
error_str = "注意, <b style='color:Orange;'>发现缺失的插件:</b></p>"
95+
for ext in ext_list:
96+
error_str+="<p>- <b style='color:Orange;'>"+ext+"</b></p> "
97+
error_str+="<b style='color:Orange;'>以上插件缺失提示仅供参考,请注意辨别实际情况下您所需要安装的插件。</b></p> "
98+
return error_str
99+
100+
def missing_loras(loras_list:[]):
101+
error_str = "注意, <b style='color:Orange;'>发现缺失的LoRA模型:</b></p>"
102+
for lora in loras_list:
103+
error_str+="<p>- <b style='color:Orange;'>"+lora+"</b></p> "
71104
return error_str
72105

73106
def click_to_download(file_name, file_url):
@@ -82,12 +115,16 @@ def click_to_download(file_name, file_url):
82115
<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {name} </a>
83116
'''
84117

118+
def note_for_save_mode():
119+
return "Core模式仅支持文生图和图生图的基本参数+ControlNet参数。All模式则会尽可能多的支持页面上的参数,但是缺点是有概率导致UI卡住,无限转圈。"
120+
121+
85122
OutputPrompt = OutputPrompt_English
86123

87124
# 改成函数调用,修改配置之后能及时刷新
88125
def init():
89126
global PNGINFO_2_LIGHTDIFFUSIONFLOW,PNGINFO_CN_2_LIGHTDIFFUSIONFLOW
90-
global OutputPrompt,Image_Components_Key
127+
global OutputPrompt,Flow_Save_mode,Auto_Fix_Params,Image_Components_Key
91128
# PNG Info的功能除了主要的选项以外其他的都靠第三方插件的主动支持,后续再考虑能否有优化的办法
92129
#print(parameters_copypaste.paste_fields)
93130
PNGINFO_2_LIGHTDIFFUSIONFLOW = {
@@ -133,40 +170,52 @@ def init():
133170
json_str = f.read()
134171
webui_settings = json.loads(json_str)
135172

136-
successed = False
173+
# 保存模式
174+
try:
175+
Flow_Save_mode = webui_settings["lightdiffusionflow-mode"]
176+
except:
177+
Flow_Save_mode = "Core"
178+
179+
# 自动纠正错误的参数
180+
try:
181+
Auto_Fix_Params = webui_settings["lightdiffusionflow-auto-fix-params"]
182+
except:
183+
Auto_Fix_Params = True
184+
185+
language_successed = False
137186
auto_language = False
138187
try:
139188
# 优先读取自己的设置
140189
if(webui_settings['lightdiffusionflow-language'] == "default"):
141190
auto_language = True
142191
elif(webui_settings['lightdiffusionflow-language'] == "english"):
143192
OutputPrompt = OutputPrompt_English
144-
successed = True
193+
language_successed = True
145194
else:
146195
OutputPrompt = OutputPrompt_Chinese
147-
successed = True
196+
language_successed = True
148197
except:
149198
OutputPrompt = OutputPrompt_English
150199

151200
# 如果是default就读取其他设置配合
152-
if(auto_language and not successed):
201+
if(auto_language and not language_successed):
153202
# 自带的本地化文件
154203
localization_files = ["zh_CN", "zh-Hans (Stable) [vladmandic]", "zh-Hans (Stable)",
155204
"zh-Hans (Testing) [vladmandic]", "zh-Hans (Testing)","chinese-all-1024","chinese-english-1024"]
156205
try:
157206
# 如果用户使用了中文汉化文件,插件也默认显示中文
158207
localization_files.index(webui_settings["localization"])
159208
OutputPrompt = OutputPrompt_Chinese
160-
successed = True
209+
language_successed = True
161210
except:
162211
pass
163212

164213
# 第三方翻译插件bilingual-localization
165-
if(not successed):
214+
if(not language_successed):
166215
try:
167216
if(webui_settings["bilingual_localization_enabled"] and webui_settings["bilingual_localization_file"] != "None"):
168217
OutputPrompt = OutputPrompt_Chinese
169-
successed = True
218+
language_successed = True
170219
except:
171220
OutputPrompt = OutputPrompt_English
172221
except:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lightdiffusionflow_version = "v2.1.2"
1+
lightdiffusionflow_version = "v2.1.3"

0 commit comments

Comments
 (0)