Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowcz007 committed Sep 7, 2024
1 parent 1a93c0f commit 2d147a3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
10 changes: 5 additions & 5 deletions nodes/ImageNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from itertools import product


# 将PIL图片转换为OpenCV格式
def pil_to_opencv(image):
open_cv_image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
Expand Down Expand Up @@ -1380,8 +1379,8 @@ def INPUT_TYPES(s):
}),
"watcher":(["disable","enable"],),
"result": ("WATCHER",),#为了激活本节点运行
"prompt": ("PROMPT",),
# "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
"prompt": ("PROMPT",),
"seed": (any_type, {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
}
}

Expand All @@ -1399,7 +1398,7 @@ def INPUT_TYPES(s):
watcher_folder=None

# 运行的函数
def run(self,file_path,white_bg,newest_files,index_variable,watcher,result,prompt):
def run(self,file_path,white_bg,newest_files,index_variable,watcher,result,prompt,seed=1):
global watcher_folder
# print('###监听:',watcher_folder,watcher,file_path,result)

Expand Down Expand Up @@ -1447,7 +1446,8 @@ def run(self,file_path,white_bg,newest_files,index_variable,watcher,result,promp
print("发生了一个未知的错误:", str(e))

# print('#prompt::::',prompt)
return {"ui": {"seed": [1]}, "result":(imgs,masks,prompt,file_names,)}
# return {"ui": {"seed": [1]}, "result":(imgs,masks,prompt,file_names,)}
return (imgs,masks,prompt,file_names,)


# TODO 扩大选区的功能,重新输出mask
Expand Down
52 changes: 27 additions & 25 deletions web/javascript/watcher_mixlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ app.registerExtension({
orig_nodeCreated?.apply(this, arguments)

// 虚拟的widget,用于更新节点,让其每次都运行
const widget = {
type: 'div',
name: 'seed',
draw (ctx, node, widget_width, y, widget_height) {}
}
// 改成了seed输入
// const widget = {
// type: 'div',
// name: 'seed',
// draw (ctx, node, widget_width, y, widget_height) {}
// }

this.addCustomWidget(widget)
// this.addCustomWidget(widget)

const watcher = this.widgets.filter(w => w.name == 'watcher')[0]

Expand Down Expand Up @@ -156,18 +157,19 @@ app.registerExtension({
this.serialize_widgets = true
}

const onExecuted = nodeType.prototype.onExecuted
nodeType.prototype.onExecuted = function (message) {
onExecuted?.apply(this, arguments)
console.log(message)
try {
let seed = this.widgets.filter(w => w.name === 'seed')[0]
if (seed) {
if (!seed.value) seed.value = 0
seed.value += 1
}
} catch (error) {}
}
// 改成seed的输入
// const onExecuted = nodeType.prototype.onExecuted
// nodeType.prototype.onExecuted = function (message) {
// onExecuted?.apply(this, arguments)
// console.log(message)
// try {
// let seed = this.widgets.filter(w => w.name === 'seed')[0]
// if (seed) {
// if (!seed.value) seed.value = 0
// seed.value += 1
// }
// } catch (error) {}
// }
}
},
async loadedGraphNode (node, app) {
Expand Down Expand Up @@ -196,13 +198,13 @@ app.registerExtension({
}
}

try {
let seed = node.widgets.filter(w => w.name === 'seed')[0]
if (seed) {
if (!seed.value) seed.value = 0
seed.value += 1
}
} catch (error) {}
// try {
// let seed = node.widgets.filter(w => w.name === 'seed')[0]
// if (seed) {
// if (!seed.value) seed.value = 0
// seed.value += 1
// }
// } catch (error) {}
}
}
})

0 comments on commit 2d147a3

Please sign in to comment.