Compare commits

..
5 Commits
9 changed files with 36 additions and 49 deletions
+4
View File
@@ -1,4 +1,8 @@
# Change Log
## v1.2.1
- Fix the input validation of the `Prompt Reader` node #37
- Fix the `Batch Loader` node not working when not connected to any node
## v1.2.0
- Add `Parameter Extractor` node #24
- Add a model matching feature to the `Prompt Reader` node #24
+1
View File
@@ -13,6 +13,7 @@ js_dest_path = os.path.join(comfy_path, "web", "extensions", "SDPromptReader")
os.makedirs(js_dest_path, exist_ok=True)
files_to_copy = [
"utils.js",
"promptDisplay.js",
"parameterDisplay.js",
"seedGen.js",
+1 -1
View File
@@ -1 +1 @@
VERSION = "1.2.0"
VERSION = "1.2.1"
+3 -10
View File
@@ -1,14 +1,6 @@
import {app} from "../../scripts/app.js";
import {ComfyWidgets} from "../../scripts/widgets.js";
// Create a read-only string widget
function createWidget(app, node, widgetName, type) {
const widget = ComfyWidgets[type](node, widgetName, ["STRING", {multiline: true}], app).widget;
widget.inputEl.readOnly = true;
widget.inputEl.style.textAlign = "center";
widget.inputEl.style.fontSize = "0.75rem";
return widget;
}
import {createTextWidget} from "./utils.js"
app.registerExtension({
name: "sd_prompt_reader.extractorDisplay",
@@ -20,7 +12,8 @@ app.registerExtension({
const result = onNodeCreated?.apply(this, arguments);
// Create widgets
const value_display = createWidget(app, this, "value_display", "STRING");
const styles = {textAlign: "center", fontSize: "0.75rem"}
const value_display = createTextWidget(app, this, "value_display", styles);
};
// Update widgets
+3 -9
View File
@@ -1,13 +1,6 @@
import {app} from "../../scripts/app.js";
import {ComfyWidgets} from "../../scripts/widgets.js";
// Create a read-only string widget with opacity set
function createWidget(app, node, widgetName) {
const widget = ComfyWidgets["STRING"](node, widgetName, ["STRING", {multiline: true}], app).widget;
widget.inputEl.readOnly = true;
widget.inputEl.style.opacity = 0.7;
return widget;
}
import {createTextWidget} from "./utils.js"
// Displays file list on the node
app.registerExtension({
@@ -20,7 +13,8 @@ app.registerExtension({
const result = onNodeCreated?.apply(this, arguments);
// Create prompt and setting widgets
const fileList = createWidget(app, this, "fileList");
const styles = {opacity: 0.7}
const fileList =createTextWidget(app, this, "fileList", styles);
return result;
};
+4 -11
View File
@@ -1,14 +1,6 @@
import {app} from "../../scripts/app.js";
import {ComfyWidgets} from "../../scripts/widgets.js";
// Create a read-only string widget
function createWidget(app, node, widgetName, type) {
const widget = ComfyWidgets[type](node, widgetName, ["STRING", {multiline: true}], app).widget;
widget.inputEl.readOnly = true;
widget.inputEl.style.textAlign = "center";
widget.inputEl.style.fontSize = "0.75rem";
return widget;
}
import {createTextWidget} from "./utils.js"
app.registerExtension({
name: "sd_prompt_reader.parameterDisplay",
@@ -20,8 +12,9 @@ app.registerExtension({
const result = onNodeCreated?.apply(this, arguments);
// Create widgets
const steps_display = createWidget(app, this, "steps_display", "STRING");
const aspect_ratio_display = createWidget(app, this, "aspect_ratio_display", "STRING");
const styles = {textAlign: "center", fontSize: "0.75rem"}
const steps_display = createTextWidget(app, this, "steps_display", styles);
const aspect_ratio_display = createTextWidget(app, this, "aspect_ratio_display", styles);
// Resize the node
const nodeWidth = this.size[0];
+5 -11
View File
@@ -1,13 +1,6 @@
import {app} from "../../scripts/app.js";
import {ComfyWidgets} from "../../scripts/widgets.js";
// Create a read-only string widget with opacity set
function createWidget(app, node, widgetName) {
const widget = ComfyWidgets["STRING"](node, widgetName, ["STRING", {multiline: true}], app).widget;
widget.inputEl.readOnly = true;
widget.inputEl.style.opacity = 0.7;
return widget;
}
import {createTextWidget} from "./utils.js"
// Displays prompt and setting on the node
app.registerExtension({
@@ -20,9 +13,10 @@ app.registerExtension({
const result = onNodeCreated?.apply(this, arguments);
// Create prompt and setting widgets
const positive = createWidget(app, this, "positive");
const negative = createWidget(app, this, "negative");
const setting = createWidget(app, this, "setting");
const styles = {opacity: 0.7}
const positive = createTextWidget(app, this, "positive", styles);
const negative = createTextWidget(app, this, "negative", styles);
const setting = createTextWidget(app, this, "setting", styles);
// Resize the node
const nodeWidth = this.size[0];
const nodeHeight = this.size[1];
+10
View File
@@ -0,0 +1,10 @@
import {app} from "../../scripts/app.js";
import {ComfyWidgets} from "../../scripts/widgets.js";
// Create a read-only string widget
export function createTextWidget(app, node, widgetName, styles = {}) {
const widget = ComfyWidgets["STRING"](node, widgetName, ["STRING", {multiline: true}], app).widget;
widget.inputEl.readOnly = true;
Object.assign(widget.inputEl.style, styles);
return widget;
}
+5 -7
View File
@@ -230,17 +230,14 @@ class SDPromptReader:
@classmethod
def IS_CHANGED(s, image, parameter_index):
image_path = folder_paths.get_annotated_filepath(image)
if image in SDPromptReader.files:
image_path = folder_paths.get_annotated_filepath(image)
else:
image_path = image
with open(Path(image_path), "rb") as f:
image_data = ImageDataReader(f)
return image_data.props
@classmethod
def VALIDATE_INPUTS(s, image, parameter_index):
if not folder_paths.exists_annotated_filepath(image):
return "Invalid image file: {}".format(image)
return True
class SDPromptSaver:
def __init__(self):
@@ -869,6 +866,7 @@ class SDBatchLoader:
RETURN_NAMES = ("IMAGE",)
OUTPUT_IS_LIST = (True,)
OUTPUT_NODE = True
FUNCTION = "load_path"
CATEGORY = "SD Prompt Reader"