Skip to content

Commit aa280a4

Browse files
author
legionfu
committed
插件改名,修复导入PNG Info出现的KeyError bug
1 parent 7cff104 commit aa280a4

11 files changed

+157
-121
lines changed

LICENSE

Lines changed: 67 additions & 38 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<img alt="" src="https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue" />
44
</p>
55

6-
# stable-diffusion-lightspeedflow
6+
# stable-diffusion-lightdiffusionflow
77

88
[**English**](./README.md) | [**中文**](./README_CN.md)
99

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<img alt="" src="https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue" />
44
</p>
55

6-
# stable-diffusion-lightspeedflow
6+
# stable-diffusion-lightdiffusionflow
77

88
[**English**](./README.md) | [**中文**](./README_CN.md)
99

javascript/state.core.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ state.core = (function () {
8383

8484
function fn_timer(){
8585

86-
fetch('/lightspeedflow/local/need_preload')
86+
fetch('/lightdiffusionflow/local/need_preload')
8787
.then(response => response.json())
8888
.then(data => {
8989
//console.log(`fn_timer ${data}`)
9090
if (data != ""){
91-
//state.core.actions.handleLightSpeedFlow([{"name":data}]);
92-
const btn1 = gradioApp().querySelector(`button#set_lightspeedflow_file`);
91+
//state.core.actions.handleLightDiffusionFlow([{"name":data}]);
92+
const btn1 = gradioApp().querySelector(`button#set_lightdiffusionflow_file`);
9393
state.utils.triggerMouseEvent(btn1);
9494
setTimeout(() => {
9595
const btn2 = gradioApp().querySelector(`button#preload_button`);
@@ -107,9 +107,9 @@ state.core = (function () {
107107
function init() {
108108

109109
//console.log(window.localization)
110-
fetch('/lightspeedflow/local/refresh_ui') // 刷新页面触发python重置图片数据
110+
fetch('/lightdiffusionflow/local/refresh_ui') // 刷新页面触发python重置图片数据
111111

112-
fetch('/lightspeedflow/local/get_imgs_elem_key') //初始化部分图片组件id, 后续设置onchanged事件
112+
fetch('/lightdiffusionflow/local/get_imgs_elem_key') //初始化部分图片组件id, 后续设置onchanged事件
113113
.then(response => response.json())
114114
.then(data => {
115115
img_elem_keys = data.split(",")
@@ -118,7 +118,7 @@ state.core = (function () {
118118
});
119119

120120
// 等上面的组件ID同步过来后 再加载其他配置
121-
fetch('/lightspeedflow/local/config.json?_=' + (+new Date()))
121+
fetch('/lightdiffusionflow/local/config.json?_=' + (+new Date()))
122122
.then(response => response.json())
123123
.then(config => {
124124
try {
@@ -477,7 +477,7 @@ state.core = (function () {
477477
// }
478478
// },
479479
applyState: function () {
480-
fetch('/lightspeedflow/local/config.json?_=' + (+new Date()))
480+
fetch('/lightdiffusionflow/local/config.json?_=' + (+new Date()))
481481
.then(response => response.json())
482482
.then(config => {
483483
try {
@@ -533,7 +533,7 @@ state.core = (function () {
533533
store.set(`img2img_seed`,state.utils.getCurSeed('img2img'))
534534
}
535535

536-
fetch('/lightspeedflow/local/lightspeedflow_config?onlyimg=true')
536+
fetch('/lightdiffusionflow/local/lightdiffusionflow_config?onlyimg=true')
537537
.then(response => response.json())
538538
.then(config => {
539539
config = JSON.parse(config)
@@ -562,18 +562,18 @@ state.core = (function () {
562562
}).catch(error => console.error('[state]: Error getting JSON file:', error));
563563

564564
//config = JSON.stringify(store.getAll(), null, 4);
565-
//fetch(`/lightspeedflow/local/ExportLightSpeedFlow?config=${config}`)
565+
//fetch(`/lightdiffusionflow/local/ExportLightDiffusionFlow?config=${config}`)
566566
},
567567

568-
handleLightSpeedFlow: function (fileInput){
568+
handleLightDiffusionFlow: function (fileInput){
569569
actions.output_log("Start parsing settings...")
570570
console.log(fileInput)
571571
let temp_fileInput = undefined
572572
try{temp_fileInput = fileInput[0]} catch(error){}
573573
if ( !temp_fileInput ) {temp_fileInput = fileInput}
574574
if ( !temp_fileInput ) {
575575
//alert('Please select a JSON file!');
576-
actions.output_log("Please select a valid lightspeedflow or image file!")
576+
actions.output_log("Please select a valid lightdiffusionflow or image file!")
577577
return;
578578
}
579579

@@ -590,11 +590,11 @@ state.core = (function () {
590590
"img_path":file_name
591591
})
592592
}
593-
fetch(`/lightspeedflow/local/png_info`, data)
593+
fetch(`/lightdiffusionflow/local/png_info`, data)
594594
.then(response => response.json())
595595
.then(data => {
596596
console.log(data)
597-
actions.importLightSpeedFlow(data)
597+
actions.importLightDiffusionFlow(data)
598598
});
599599
}
600600
else{
@@ -604,7 +604,7 @@ state.core = (function () {
604604
const reader = new FileReader();
605605
reader.onload = function (event) {
606606
console.log(event)
607-
actions.importLightSpeedFlow(event.target.result)
607+
actions.importLightDiffusionFlow(event.target.result)
608608
};
609609
try{ reader.readAsText(file); } catch (error) {
610610
console.log("read from python")
@@ -616,27 +616,27 @@ state.core = (function () {
616616
"file_path":temp_fileInput.name
617617
})
618618
}
619-
fetch(`/lightspeedflow/local/read_file`, data)
619+
fetch(`/lightdiffusionflow/local/read_file`, data)
620620
.then(response => response.json())
621621
.then(data => {
622622
//console.log(data)
623-
actions.importLightSpeedFlow(data)
623+
actions.importLightDiffusionFlow(data)
624624
});
625625
}
626626

627627
}
628628
}
629629
return fileInput
630630
},
631-
importLightSpeedFlow: function (inputData){
631+
importLightDiffusionFlow: function (inputData){
632632

633633
forEachElement_WithoutTabs(IMAGES_WITHOUT_PREFIX, (image_id) => {
634634
state.utils.clearImage(getElement(image_id));
635635
});
636636

637637
let json_obj = {}
638638
try { json_obj = JSON.parse(inputData) } catch (error) {
639-
actions.output_log("Please select a valid lightspeedflow or image file!")
639+
actions.output_log("Please select a valid lightdiffusionflow or image file!")
640640
return;
641641
}
642642
console.log(json_obj)
@@ -685,13 +685,15 @@ state.core = (function () {
685685

686686
},
687687
output_log: function (msg, style=""){
688-
fetch(`/lightspeedflow/local/output_log?msg=${msg}&style=${style}`)
688+
fetch(`/lightdiffusionflow/local/output_log?msg=${msg}&style=${style}`).then(() => {
689+
gradioApp().getElementById("txt2img_invisible_refresh_log").click();
690+
});
689691
},
690692
output_warning: function (msg, style="color:Orange;"){
691-
fetch(`/lightspeedflow/local/output_log?msg=${msg}&style=${style}`)
693+
actions.output_log(msg,style)
692694
},
693695
output_error: function (msg, style="color:Tomato;"){
694-
fetch(`/lightspeedflow/local/output_log?msg=${msg}&style=${style}`)
696+
actions.output_log(msg,style)
695697
}
696698
};
697699

javascript/state.ext.general.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function general_ext_main(tab){
247247
}
248248

249249
if(title == undefined
250-
|| title.toLowerCase() == "lightspeedflow" // 自己存自己就不用了
250+
|| title.toLowerCase() == "lightdiffusionflow" // 自己存自己就不用了
251251
){continue}
252252

253253
let translations = state.utils.reverseTranslation(title)

javascript/state.utils.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ state = window.state;
44
state.utils = {
55

66
testFunction: function testFunction() {
7-
87
//console.log(state.extensions)
9-
let str = "chilloutmix_Ni.safetensors [7234b76e42]"
10-
let res = str.search(/\[[0-9A-Fa-f]{10}\]/)
11-
res = str.substring(res,res+12)
12-
console.log(res)
138
},
149

1510
searchCheckPointByHash: async function searchCheckPointByHash(hash){
@@ -228,7 +223,7 @@ state.utils = {
228223
console.warn('[state]: Error:', error);
229224
}
230225

231-
fetch(`/lightspeedflow/local/imgs_callback`, data)
226+
fetch(`/lightdiffusionflow/local/imgs_callback`, data)
232227
});
233228
}, 150);
234229
},
@@ -389,11 +384,13 @@ state.utils = {
389384
state.core.actions.output_error(`\'${option_name}\' import failed! The option \'${value}\' was not found!`)
390385
}
391386
if(hash_pos != -1){
387+
let model_name = value
392388
let hash_str = localized_value.substring(hash_pos,hash_pos+12)
393389
state.utils.searchCheckPointByHash(hash_str).then( downloadUrl => {
394390
if(downloadUrl != undefined){
395-
state.core.actions.output_warning(`click to download \
396-
<a style ="text-decoration:underline;color:cornflowerblue;", href="${downloadUrl}"> ${value} </a>`)
391+
let warning_str = encodeURIComponent(`click to download \
392+
<a style ='text-decoration:underline;color:cornflowerblue;', href='${downloadUrl}'> ${model_name} </a>`)
393+
state.core.actions.output_warning(warning_str)
397394
}
398395
});
399396
}
@@ -508,7 +505,7 @@ state.utils = {
508505
console.log(url)
509506
const link = document.createElement('a');
510507
link.href = url;
511-
link.download = fileName + '.lightspeedflow';
508+
link.download = fileName + '.lightdiffusionflow';
512509
document.body.appendChild(link);
513510
link.click();
514511
link.parentNode.removeChild(link);

scripts/lightspeedflow_config.py renamed to scripts/lightdiffusionflow_config.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import json
22
import modules.shared as shared
33

4-
PNGINFO_2_LIGHTSPEEDFLOW = {}
5-
PNGINFO_CN_2_LIGHTSPEEDFLOW = {}
4+
PNGINFO_2_LIGHTDIFFUSIONFLOW = {}
5+
PNGINFO_CN_2_LIGHTDIFFUSIONFLOW = {}
66
Image_Components_Key = {}
77

88
# 改成函数调用,修改配置之后能及时刷新
99
def init():
10-
global PNGINFO_2_LIGHTSPEEDFLOW,PNGINFO_CN_2_LIGHTSPEEDFLOW,Image_Components_Key
10+
global PNGINFO_2_LIGHTDIFFUSIONFLOW,PNGINFO_CN_2_LIGHTDIFFUSIONFLOW,Image_Components_Key
1111
# PNG Info的功能除了主要的选项以外其他的都靠第三方插件的主动支持,后续再考虑能否有优化的办法
1212
#print(parameters_copypaste.paste_fields)
13-
PNGINFO_2_LIGHTSPEEDFLOW = {
13+
PNGINFO_2_LIGHTDIFFUSIONFLOW = {
1414
"Prompt": "state-txt2img_prompt",
1515
"Negative prompt": "state-txt2img_neg_prompt",
1616
"Steps": "state-txt2img_steps",
@@ -31,12 +31,15 @@ def init():
3131
"ENSD": "setting_eta_noise_seed_delta"
3232
}
3333

34-
PNGINFO_CN_2_LIGHTSPEEDFLOW = {
34+
PNGINFO_CN_2_LIGHTDIFFUSIONFLOW = {
35+
"Module": "state-ext-control-net-txt2img_0-preprocessor",
3536
"preprocessor": "state-ext-control-net-txt2img_0-preprocessor",
3637
"model": "state-ext-control-net-txt2img_0-model",
3738
"weight": "state-ext-control-net-txt2img_0-control-weight",
3839
"starting": "state-ext-control-net-txt2img_0-starting-control-step",
3940
"ending": "state-ext-control-net-txt2img_0-guidance-end-(t)",
41+
"guidance start": "state-ext-control-net-txt2img_0-starting-control-step",
42+
"guidance end": "state-ext-control-net-txt2img_0-ending-control-step",
4043
"resize mode": "state-ext-control-net-txt2img_0-resize-mode",
4144
"pixel perfect": "state-ext-control-net-txt2img_0-pixel-perfect",
4245
"control mode": "state-ext-control-net-txt2img_0-control-mode",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lightdiffusionflow_version = "v2.0.2"

scripts/lightspeedflow_version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)