Skip to content

Commit 7cf255f

Browse files
author
legionfu
committed
增加记录额外LoRA模型数据,以便导入时从Civitai搜索缺失的lora模型。
1 parent bc50812 commit 7cf255f

File tree

4 files changed

+213
-77
lines changed

4 files changed

+213
-77
lines changed

ChangeLog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 2.1.4
2+
3+
### Features:
4+
* 增加记录额外LoRA模型数据,以便导入时从Civitai搜索缺失的lora模型。
5+
6+
### Bug Fixes:
7+
* 修复了部分已知的参数设置失败的问题,如ControlNet在Canny模式下的"Canny Low/Hight Threshold"等参数。
8+
9+
110
## 2.1.3
211

312
### Features:

javascript/state.core.js

Lines changed: 66 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -639,63 +639,82 @@ state.core = (function () {
639639
store.set(`img2img_seed`,state.utils.getCurSeed('img2img'))
640640
}
641641

642-
fetch('/lightdiffusionflow/local/lightdiffusionflow_config?onlyimg=true')
642+
643+
fetch('/lightdiffusionflow/local/lightdiffusionflow_config?data2export=true')
644+
.then(response => response.json())
645+
.then(config => {
646+
647+
config = JSON.parse(config)
648+
stored_config = store.getAll()
649+
650+
let data = {
651+
method: 'POST',
652+
headers: { 'Content-Type': 'application/json' },
653+
body: JSON.stringify({
654+
"config_data":stored_config
655+
})
656+
}
657+
fetch(`/lightdiffusionflow/local/parse_lora_info`, data)
643658
.then(response => response.json())
644-
.then(config => {
645-
config = JSON.parse(config)
646-
stored_config = store.getAll()
659+
.then(response_lora_info => {
647660

648-
for (let key in config){
649-
if(config[key] != ""){
650-
stored_config[key] = config[key]
651-
}
652-
}
661+
for (let key in response_lora_info){
662+
stored_config[key] = response_lora_info[key]
663+
}
653664

654-
for (let key in stored_config){
655-
if(key.indexOf("allow-preview") !== -1 && key.indexOf("ext-control-net") !== -1)
656-
{
657-
console.log("allow-preview改成false")
658-
stored_config[key] = "false"
659-
}
665+
for (let key in config){
666+
if(config[key] != ""){
667+
stored_config[key] = config[key]
660668
}
669+
}
661670

662-
var checkTime = function (i) {
663-
if (i < 10) { i = "0" + i; }
664-
return i;
665-
}
666-
let nowdate = new Date();
667-
let year = String(nowdate.getFullYear())
668-
let month = String(checkTime(nowdate.getMonth() + 1))
669-
let day = String(checkTime(nowdate.getDate()))
670-
let h = String(checkTime(nowdate.getHours()))
671-
let m = String(checkTime(nowdate.getMinutes()))
672-
let s = String(checkTime(nowdate.getSeconds()))
673-
let time_str = year+month+day+h+m+s
674-
675-
filename = 'flow-'+time_str+'.flow'
676-
filename = prompt("Export workflow as:", filename);
677-
if (!filename) return;
678-
if (!filename.toLowerCase().endsWith(".flow")) {
679-
filename += ".flow";
671+
for (let key in stored_config){
672+
if(key.indexOf("allow-preview") !== -1 && key.indexOf("ext-control-net") !== -1)
673+
{
674+
console.log("allow-preview改成false")
675+
stored_config[key] = "false"
680676
}
681-
if(filename != ".flow"){
682-
// const handle = window.showDirectoryPicker();
683-
// console.log(handle)
684-
685-
state.utils.saveFile(filename, stored_config);
686-
687-
fetch('https://api.lightflow.ai/openapi/access?action=export')
688-
.then(response => response.json())
689-
.then(config => {
690-
console.log(config)
691-
}).catch(function(e) {
692-
console.log("Oops, export callback error!");
693-
});
677+
}
694678

695-
}
679+
var checkTime = function (i) {
680+
if (i < 10) { i = "0" + i; }
681+
return i;
682+
}
683+
let nowdate = new Date();
684+
let year = String(nowdate.getFullYear())
685+
let month = String(checkTime(nowdate.getMonth() + 1))
686+
let day = String(checkTime(nowdate.getDate()))
687+
let h = String(checkTime(nowdate.getHours()))
688+
let m = String(checkTime(nowdate.getMinutes()))
689+
let s = String(checkTime(nowdate.getSeconds()))
690+
let time_str = year+month+day+h+m+s
691+
692+
filename = 'flow-'+time_str+'.flow'
693+
filename = prompt("Export workflow as:", filename);
694+
if (!filename) return;
695+
if (!filename.toLowerCase().endsWith(".flow")) {
696+
filename += ".flow";
697+
}
698+
if(filename != ".flow"){
699+
// const handle = window.showDirectoryPicker();
700+
// console.log(handle)
701+
702+
state.utils.saveFile(filename, stored_config);
703+
704+
// fetch('https://api.lightflow.ai/openapi/access?action=export')
705+
// .then(response => response.json())
706+
// .then(config => {
707+
// console.log(config)
708+
// }).catch(function(e) {
709+
// console.log("Oops, export callback error!");
710+
// });
711+
712+
}
696713

697714
}).catch(error => console.error('[state]: Error getting Flow file:', error));
698715

716+
}).catch(error => console.error('[state]: Error getting Flow file:', error));
717+
699718
//config = JSON.stringify(store.getAll(), null, 4);
700719
//fetch(`/lightdiffusionflow/local/ExportLightDiffusionFlow?config=${config}`)
701720
},

scripts/lightdiffusionflow_config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def click_to_download(file_name, file_url):
5656
<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {file_name} </a>
5757
'''
5858

59+
def download_link(file_name, file_url):
60+
return f'''<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {file_name} </a>'''
61+
5962
def note_for_save_mode():
6063
return "Core mode only supports basic parameters for Text-to-Image and Image-to-Image, along with ControlNet parameters. \
6164
The All mode, on the other hand, aims to support as many parameters as possible on the page, \
@@ -121,6 +124,9 @@ def click_to_download(file_name, file_url):
121124
<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {name} </a>
122125
'''
123126

127+
def download_link(file_name, file_url):
128+
return f'''<a style ='text-decoration:underline;color:cornflowerblue;', target="_blank", href='{file_url}'> {file_name} </a>'''
129+
124130
def note_for_save_mode():
125131
return "Core模式仅支持文生图和图生图的基本参数+ControlNet参数。All模式则会尽可能多的支持页面上的参数,但是缺点是有概率导致UI卡住,无限转圈。"
126132

0 commit comments

Comments
 (0)