This commit is contained in:
shadowcz007
2024-03-24 20:38:55 +08:00
parent 8e78f9786c
commit df637e8196
3 changed files with 20 additions and 10 deletions
+2 -1
View File
@@ -730,7 +730,8 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"GLIGENTextBoxApply_Advanced":"GLIGEN TextBox Apply ♾️Mixlab",
"GridDisplayAndSave":"Grid Display And Save",
"GridInput":"Grid Input",
"GridOutput":"Grid Output"
"GridOutput":"Grid Output",
"GetImageSize_":"Get Image Size"
}
# web ui的节点功能
+8 -6
View File
@@ -697,21 +697,23 @@
// 种子的处理
function randomSeed(seed, data) {
let max_seed = 4294967295
//1849378600828930
for (const id in data) {
if (data[id].inputs.seed != undefined
&& !Array.isArray(data[id].inputs.seed) //如果是数组,则由其他节点控制
&& ['increment', 'decrement', 'randomize'].includes(seed[id])) {
data[id].inputs.seed = Math.round(Math.random() * 1849378600828930)
data[id].inputs.seed = Math.round(Math.random() * max_seed)
// console.log('new Seed', data[id])
}
if (data[id].inputs.noise_seed != undefined
&& !Array.isArray(data[id].inputs.noise_seed) //如果是数组,则由其他节点控制
&& ['increment', 'decrement', 'randomize'].includes(seed[id])) {
data[id].inputs.noise_seed = Math.round(Math.random() * 1849378600828930)
data[id].inputs.noise_seed = Math.round(Math.random() * max_seed)
}
// class_type:"Seed_"
if (data[id].class_type == "Seed_") {
data[id].inputs.seed = Math.round(Math.random() * 1849378600828930)
data[id].inputs.seed = Math.round(Math.random() * max_seed)
}
console.log('new Seed', data[id])
}
@@ -1905,7 +1907,7 @@
function createUI(data, share = true) {
// appData.input, appData.output, appData.seed, share, appData.link
const { input: inputData, output: outputData, data: workflow, seed, link, name } = data;
const { input: inputData, output: outputData, data: workflow, seed, seedTitle, link, name } = data;
let mainDiv = document.createElement('div');
@@ -2003,7 +2005,7 @@
let em = document.createElement('em');
let emText = document.createElement('span');
emText.innerText = `#${id} ${s.toUpperCase()}`;
emText.innerText = `#${seedTitle && seedTitle[id] ? seedTitle[id] : id} ${s.toUpperCase()}`;
em.appendChild(emText);
seedInput.appendChild(em)
@@ -2024,7 +2026,7 @@
data.seed[id] = 'randomize';
inSeed.style.display = 'none'
}
emText.innerText = `#${id} ${data.seed[id].toUpperCase()}`;
emText.innerText = `#${seedTitle && seedTitle[id] ? seedTitle[id] : id} ${data.seed[id].toUpperCase()}`;
});
seedInput.appendChild(inSeed);
+10 -3
View File
@@ -101,6 +101,7 @@ async function extractInputAndOutputData (
let input = []
let output = []
const seed = {}
const seedTitle = {}
for (const id in data) {
if (data.hasOwnProperty(id)) {
@@ -193,12 +194,17 @@ async function extractInputAndOutputData (
output[outputIds.indexOf(id)] = { ...data[id], title: node.title, id }
}
if (node.type === 'KSampler' || node.type == 'SamplerCustom') {
if (
node.type === 'KSampler' ||
node.type == 'SamplerCustom' ||
node.type === 'ChinesePrompt_Mix'
) {
// seed 的类型收集
try {
seed[id] = node.widgets.filter(
w => w.name === 'seed' || w.name == 'noise_seed'
)[0].linkedWidgets[0].value
seedTitle[id] = node.title
} catch (error) {}
}
}
@@ -208,7 +214,7 @@ async function extractInputAndOutputData (
input = input.filter(i => i)
output = output.filter(i => i)
return { input, output, seed }
return { input, output, seed, seedTitle }
}
function getUrl () {
@@ -281,7 +287,7 @@ async function save (json, download = false, showInfo = true) {
try {
let data = await app.graphToPrompt()
let { input, output, seed } = await extractInputAndOutputData(
let { input, output, seed, seedTitle } = await extractInputAndOutputData(
data,
inputIds,
outputIds
@@ -301,6 +307,7 @@ async function save (json, download = false, showInfo = true) {
input,
output,
seed, //控制是fixed 还是random
seedTitle,
share_prefix,
link,
category,