Add ksampler advance denoise

This commit is contained in:
pythongosssss
2023-06-18 14:46:03 +01:00
parent fe25722417
commit 6bcc673821
2 changed files with 57 additions and 0 deletions
+3
View File
@@ -2,6 +2,8 @@
> ⚠️ **If updating from a version prior to 2023-06-18**: Many of the nodes have been renamed to include `pysssss` to prevent conflicts with other nodes. If you get missing nodes, please replace them with the new names.
> ⚠️ **Auto installation process is still a new feature in need of testing, if you have any problems please log an issue**
# Installation
1. Clone the repository:
@@ -80,6 +82,7 @@ Moved to: https://github.com/pythongosssss/ComfyUI-WD14-Tagger
- ✨ Add Link Render Mode setting to choose how links are rendered
- ✨ Add Constrain Image node for resizing nodes to a min/max resolution with optional cropping
- ✨ Add Show Image On Menu to include the latest image output on the menu
- ✨ Add KSamplerAdvanced simple denoise prompt for configuring the node using steps + denoise
### Other
- ♻️ Include [canvas2svg](https://gliffy.github.io/canvas2svg/) for SVG export in assets to prevent downloading at runtime
+54
View File
@@ -0,0 +1,54 @@
import { app } from "/scripts/app.js";
app.registerExtension({
name: "pysssss.KSamplerAdvDenoise",
async beforeRegisterNodeDef(nodeType) {
// Add menu options to conver to/from widgets
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
nodeType.prototype.getExtraMenuOptions = function (_, options) {
const r = origGetExtraMenuOptions?.apply?.(this, arguments);
let stepsWidget = null;
let startAtWidget = null;
let endAtWidget = null;
for (const w of this.widgets || []) {
if (w.name === "steps") {
stepsWidget = w;
} else if (w.name === "start_at_step") {
startAtWidget = w;
} else if (w.name === "end_at_step") {
endAtWidget = w;
}
}
if (stepsWidget && startAtWidget && endAtWidget) {
options.push(
{
content: "Set Denoise",
callback: () => {
const steps = +prompt("How many steps do you want?", 15);
if (isNaN(steps)) {
return;
}
const denoise = +prompt("How much denoise? (0-1)", 0.5);
if (isNaN(denoise)) {
return;
}
stepsWidget.value = Math.floor(steps / Math.max(0, Math.min(1, denoise)));
stepsWidget.callback?.(stepsWidget.value);
startAtWidget.value = stepsWidget.value - steps;
startAtWidget.callback?.(startAtWidget.value);
endAtWidget.value = stepsWidget.value;
endAtWidget.callback?.(endAtWidget.value);
},
},
null
);
}
return r;
};
},
});