【AI繪畫(huà)】-【fooocus】-【200+風(fēng)格測(cè)試】

fooocus是很好的AI繪圖工具,自從裝好后畫(huà)了不少圖,都很喜歡。
希望能為每個(gè)風(fēng)格跑一張默認(rèn)的圖,跑完所有風(fēng)格,了解一下,漲漲見(jiàn)識(shí)。
于是寫(xiě)了下面一段 JS ,作用是可以控制 foocus 界面遍歷所有風(fēng)格,每個(gè)風(fēng)格畫(huà)一張圖,在控制臺(tái)簡(jiǎn)單調(diào)試了一下,可以運(yùn)行;?
```
var i = 0
style_list = document.querySelector("#component-22").querySelectorAll("input")
const observer = new MutationObserver((mutationsRecord)=>{
? ? console.log('第' + i + '次DOM元素變化;' + new Date())
? ? console.log(mutationsRecord)
? ? if (i < 0 || i >= style_list.length) {
? ? ? ? // 全部風(fēng)格都畫(huà)完了可退出監(jiān)聽(tīng)
? ? ? ? observer.disconnect()
? ? ? ? console.log('第' + i + '次;全部風(fēng)格都畫(huà)完了,退出監(jiān)聽(tīng);' + new Date())
? ? } else if (!document.querySelector("#component-10").disabled) {
? ? ? ? // 點(diǎn)擊生成按鈕
? ? ? ? document.querySelector("#component-10").click()
? ? ? ? // 游標(biāo)自增
? ? ? ? i = i + 1
? ? ? ? // 切換風(fēng)格
? ? ? ? style_list[i].parentElement.click()
? ? ? ? console.log('END style_list[i].checked = true ;第' + i + '次切換風(fēng)格' + new Date())
? ? ? ??
? ? }
}
)
observer.observe(document.querySelector("#component-10"), {
? ? attributes: true,
? ? childList: true,
? ? subtree: true
})
document.querySelector("#component-10").click()
```
效果是這樣的

可以看到每張圖的風(fēng)格字段 style 已經(jīng)不同,整個(gè)過(guò)程是自動(dòng)執(zhí)行的。
我已經(jīng)把筆記本放到空氣凈化器上開(kāi)跑了,GPU 溫度穩(wěn)在?60 度上下。
原理是監(jiān)聽(tīng)生成按鈕,如果灰變白了,說(shuō)明上一張圖畫(huà)完了,切風(fēng)格畫(huà)下一張,直到遍歷完所有的風(fēng)格后停止監(jiān)聽(tīng)。








