Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e011711600 |
@@ -39,18 +39,38 @@ class ComfyUIDeployExternalImageBatch:
|
|||||||
|
|
||||||
CATEGORY = "image"
|
CATEGORY = "image"
|
||||||
|
|
||||||
|
def process_image(self, image):
|
||||||
|
image = ImageOps.exif_transpose(image)
|
||||||
|
image = image.convert("RGB")
|
||||||
|
image = np.array(image).astype(np.float32) / 255.0
|
||||||
|
image_tensor = torch.from_numpy(image)[None,]
|
||||||
|
return image_tensor
|
||||||
|
|
||||||
def run(self, input_id, images=None, default_value=None, display_name=None, description=None):
|
def run(self, input_id, images=None, default_value=None, display_name=None, description=None):
|
||||||
|
import requests
|
||||||
|
import zipfile
|
||||||
|
import io
|
||||||
|
|
||||||
processed_images = []
|
processed_images = []
|
||||||
try:
|
try:
|
||||||
images_list = json.loads(images) # Assuming images is a JSON array string
|
images_list = json.loads(images) # Assuming images is a JSON array string
|
||||||
print(images_list)
|
print(images_list)
|
||||||
for img_input in images_list:
|
for img_input in images_list:
|
||||||
if img_input.startswith('http'):
|
if img_input.startswith('http'):
|
||||||
import requests
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
print("Fetching image from url: ", img_input)
|
print("Fetching image from url: ", img_input)
|
||||||
response = requests.get(img_input)
|
response = requests.get(img_input)
|
||||||
image = Image.open(BytesIO(response.content))
|
image = Image.open(BytesIO(response.content))
|
||||||
|
elif img_input.startswith('http') and img_input.endswith('.zip'):
|
||||||
|
print("Fetching zip file from url: ", img_input)
|
||||||
|
response = requests.get(img_input)
|
||||||
|
zip_file = zipfile.ZipFile(io.BytesIO(response.content))
|
||||||
|
for file_name in zip_file.namelist():
|
||||||
|
if file_name.lower().endswith(('.png', '.jpg', '.jpeg')):
|
||||||
|
with zip_file.open(file_name) as file:
|
||||||
|
image = Image.open(file)
|
||||||
|
image = self.process_image(image)
|
||||||
|
processed_images.append(image)
|
||||||
elif img_input.startswith('data:image/png;base64,') or img_input.startswith('data:image/jpeg;base64,') or img_input.startswith('data:image/jpg;base64,'):
|
elif img_input.startswith('data:image/png;base64,') or img_input.startswith('data:image/jpeg;base64,') or img_input.startswith('data:image/jpg;base64,'):
|
||||||
import base64
|
import base64
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|||||||
+65
-66
@@ -192,13 +192,11 @@ const ext = {
|
|||||||
|
|
||||||
registerCustomNodes() {
|
registerCustomNodes() {
|
||||||
/** @type {LGraphNode}*/
|
/** @type {LGraphNode}*/
|
||||||
class ComfyDeploy extends LGraphNode {
|
class ComfyDeploy {
|
||||||
|
color = LGraphCanvas.node_colors.yellow.color;
|
||||||
|
bgcolor = LGraphCanvas.node_colors.yellow.bgcolor;
|
||||||
|
groupcolor = LGraphCanvas.node_colors.yellow.groupcolor;
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
|
||||||
this.color = LGraphCanvas.node_colors.yellow.color;
|
|
||||||
this.bgcolor = LGraphCanvas.node_colors.yellow.bgcolor;
|
|
||||||
this.groupcolor = LGraphCanvas.node_colors.yellow.groupcolor;
|
|
||||||
|
|
||||||
if (!this.properties) {
|
if (!this.properties) {
|
||||||
this.properties = {};
|
this.properties = {};
|
||||||
this.properties.workflow_name = "";
|
this.properties.workflow_name = "";
|
||||||
@@ -206,75 +204,65 @@ const ext = {
|
|||||||
this.properties.version = "";
|
this.properties.version = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addWidget(
|
ComfyWidgets.STRING(
|
||||||
"text",
|
this,
|
||||||
"workflow_name",
|
"workflow_name",
|
||||||
this.properties.workflow_name,
|
[
|
||||||
(v) => {
|
"",
|
||||||
this.properties.workflow_name = v;
|
{
|
||||||
|
default: this.properties.workflow_name,
|
||||||
|
multiline: false,
|
||||||
},
|
},
|
||||||
{ multiline: false }
|
],
|
||||||
|
app,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.addWidget(
|
ComfyWidgets.STRING(
|
||||||
"text",
|
this,
|
||||||
"workflow_id",
|
"workflow_id",
|
||||||
this.properties.workflow_id,
|
[
|
||||||
(v) => {
|
"",
|
||||||
this.properties.workflow_id = v;
|
{
|
||||||
|
default: this.properties.workflow_id,
|
||||||
|
multiline: false,
|
||||||
},
|
},
|
||||||
{ multiline: false }
|
],
|
||||||
|
app,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.addWidget(
|
ComfyWidgets.STRING(
|
||||||
"text",
|
this,
|
||||||
"version",
|
"version",
|
||||||
this.properties.version,
|
["", { default: this.properties.version, multiline: false }],
|
||||||
(v) => {
|
app,
|
||||||
this.properties.version = v;
|
|
||||||
},
|
|
||||||
{ multiline: false }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// this.widgets.forEach((w) => {
|
||||||
|
// // w.computeSize = () => [200,10]
|
||||||
|
// w.computedHeight = 2;
|
||||||
|
// })
|
||||||
|
|
||||||
this.widgets_start_y = 10;
|
this.widgets_start_y = 10;
|
||||||
|
this.setSize(this.computeSize());
|
||||||
|
|
||||||
|
// const config = { };
|
||||||
|
|
||||||
|
// console.log(this);
|
||||||
this.serialize_widgets = true;
|
this.serialize_widgets = true;
|
||||||
this.isVirtualNode = true;
|
this.isVirtualNode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onExecute() {
|
|
||||||
// This method is called when the node is executed
|
|
||||||
// You can add any necessary logic here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSerialize(o) {
|
// Load default visibility
|
||||||
// This method is called when the node is being serialized
|
|
||||||
// Ensure all necessary data is saved
|
|
||||||
if (!o.properties) {
|
|
||||||
o.properties = {};
|
|
||||||
}
|
|
||||||
o.properties.workflow_name = this.properties.workflow_name;
|
|
||||||
o.properties.workflow_id = this.properties.workflow_id;
|
|
||||||
o.properties.version = this.properties.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
onConfigure(o) {
|
LiteGraph.registerNodeType(
|
||||||
// This method is called when the node is being configured (e.g., when loading a saved graph)
|
"ComfyDeploy",
|
||||||
// Ensure all necessary data is restored
|
Object.assign(ComfyDeploy, {
|
||||||
if (o.properties) {
|
|
||||||
this.properties = { ...this.properties, ...o.properties };
|
|
||||||
this.widgets[0].value = this.properties.workflow_name || "";
|
|
||||||
this.widgets[1].value = this.properties.workflow_id || "";
|
|
||||||
this.widgets[2].value = this.properties.version || "1";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register the node type
|
|
||||||
LiteGraph.registerNodeType("ComfyDeploy", Object.assign(ComfyDeploy, {
|
|
||||||
title: "Comfy Deploy",
|
|
||||||
title_mode: LiteGraph.NORMAL_TITLE,
|
title_mode: LiteGraph.NORMAL_TITLE,
|
||||||
|
title: "Comfy Deploy",
|
||||||
collapsable: true,
|
collapsable: true,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
ComfyDeploy.category = "deploy";
|
ComfyDeploy.category = "deploy";
|
||||||
},
|
},
|
||||||
@@ -454,11 +442,14 @@ function createDynamicUIHtml(data) {
|
|||||||
Object.values(data.custom_nodes).forEach((node) => {
|
Object.values(data.custom_nodes).forEach((node) => {
|
||||||
html += `
|
html += `
|
||||||
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 16px;">
|
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 16px;">
|
||||||
<a href="${node.url
|
<a href="${
|
||||||
}" target="_blank" style="font-size: 18px; font-weight: semibold; color: white; text-decoration: none;">${node.name
|
node.url
|
||||||
|
}" target="_blank" style="font-size: 18px; font-weight: semibold; color: white; text-decoration: none;">${
|
||||||
|
node.name
|
||||||
}</a>
|
}</a>
|
||||||
<p style="font-size: 14px; color: #4b5563;">${node.hash}</p>
|
<p style="font-size: 14px; color: #4b5563;">${node.hash}</p>
|
||||||
${node.warning
|
${
|
||||||
|
node.warning
|
||||||
? `<p style="font-size: 14px; color: #d69e2e;">${node.warning}</p>`
|
? `<p style="font-size: 14px; color: #d69e2e;">${node.warning}</p>`
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
@@ -475,7 +466,8 @@ function createDynamicUIHtml(data) {
|
|||||||
Object.entries(data.models).forEach(([section, items]) => {
|
Object.entries(data.models).forEach(([section, items]) => {
|
||||||
html += `
|
html += `
|
||||||
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 8px; padding-bottom: 8px;">
|
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 8px; padding-bottom: 8px;">
|
||||||
<h3 style="font-size: 18px; font-weight: semibold; margin-bottom: 8px;">${section.charAt(0).toUpperCase() + section.slice(1)
|
<h3 style="font-size: 18px; font-weight: semibold; margin-bottom: 8px;">${
|
||||||
|
section.charAt(0).toUpperCase() + section.slice(1)
|
||||||
}</h3>`;
|
}</h3>`;
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
html += `<p style="font-size: 14px; color: ${textColor};">${item.name}</p>`;
|
html += `<p style="font-size: 14px; color: ${textColor};">${item.name}</p>`;
|
||||||
@@ -492,7 +484,8 @@ function createDynamicUIHtml(data) {
|
|||||||
Object.entries(data.files).forEach(([section, items]) => {
|
Object.entries(data.files).forEach(([section, items]) => {
|
||||||
html += `
|
html += `
|
||||||
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 8px; padding-bottom: 8px;">
|
<div style="border-bottom: 1px solid #e2e8f0; padding-top: 8px; padding-bottom: 8px;">
|
||||||
<h3 style="font-size: 18px; font-weight: semibold; margin-bottom: 8px;">${section.charAt(0).toUpperCase() + section.slice(1)
|
<h3 style="font-size: 18px; font-weight: semibold; margin-bottom: 8px;">${
|
||||||
|
section.charAt(0).toUpperCase() + section.slice(1)
|
||||||
}</h3>`;
|
}</h3>`;
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
html += `<p style="font-size: 14px; color: ${textColor};">${item.name}</p>`;
|
html += `<p style="font-size: 14px; color: ${textColor};">${item.name}</p>`;
|
||||||
@@ -1013,9 +1006,11 @@ export class LoadingDialog extends ComfyDialog {
|
|||||||
showLoading(title, message) {
|
showLoading(title, message) {
|
||||||
this.show(`
|
this.show(`
|
||||||
<div style="width: 400px; display: flex; gap: 18px; flex-direction: column; overflow: unset">
|
<div style="width: 400px; display: flex; gap: 18px; flex-direction: column; overflow: unset">
|
||||||
<h3 style="margin: 0px; display: flex; align-items: center; justify-content: center; gap: 12px;">${title} ${this.loadingIcon
|
<h3 style="margin: 0px; display: flex; align-items: center; justify-content: center; gap: 12px;">${title} ${
|
||||||
|
this.loadingIcon
|
||||||
}</h3>
|
}</h3>
|
||||||
${message
|
${
|
||||||
|
message
|
||||||
? `<label style="max-width: 100%; white-space: pre-wrap; word-wrap: break-word;">${message}</label>`
|
? `<label style="max-width: 100%; white-space: pre-wrap; word-wrap: break-word;">${message}</label>`
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
@@ -1284,16 +1279,20 @@ export class ConfigDialog extends ComfyDialog {
|
|||||||
</label>
|
</label>
|
||||||
<label style="color: white; width: 100%;">
|
<label style="color: white; width: 100%;">
|
||||||
Endpoint:
|
Endpoint:
|
||||||
<input id="endpoint" style="margin-top: 8px; width: 100%; height:40px; box-sizing: border-box; padding: 0px 6px;" type="text" value="${data.endpoint
|
<input id="endpoint" style="margin-top: 8px; width: 100%; height:40px; box-sizing: border-box; padding: 0px 6px;" type="text" value="${
|
||||||
|
data.endpoint
|
||||||
}">
|
}">
|
||||||
</label>
|
</label>
|
||||||
<div style="color: white;">
|
<div style="color: white;">
|
||||||
API Key: User / Org <button style="font-size: 18px;">${data.displayName ?? ""
|
API Key: User / Org <button style="font-size: 18px;">${
|
||||||
|
data.displayName ?? ""
|
||||||
}</button>
|
}</button>
|
||||||
<input id="apiKey" style="margin-top: 8px; width: 100%; height:40px; box-sizing: border-box; padding: 0px 6px;" type="password" value="${data.apiKey
|
<input id="apiKey" style="margin-top: 8px; width: 100%; height:40px; box-sizing: border-box; padding: 0px 6px;" type="password" value="${
|
||||||
|
data.apiKey
|
||||||
}">
|
}">
|
||||||
<button id="loginButton" style="margin-top: 8px; width: 100%; height:40px; box-sizing: border-box; padding: 0px 6px;">
|
<button id="loginButton" style="margin-top: 8px; width: 100%; height:40px; box-sizing: border-box; padding: 0px 6px;">
|
||||||
${data.apiKey ? "Re-login with ComfyDeploy" : "Login with ComfyDeploy"
|
${
|
||||||
|
data.apiKey ? "Re-login with ComfyDeploy" : "Login with ComfyDeploy"
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user