minor cleanups to last PR

This commit is contained in:
Alex "mcmonkey" Goodwin
2024-09-13 14:52:05 +09:00
parent 722554fe44
commit 0325121fe0
4 changed files with 6 additions and 10 deletions

View File

@@ -3,7 +3,6 @@ import numpy as np
import comfy.utils
from server import PromptServer, BinaryEventTypes
import time, io, struct
import cv2
SPECIAL_ID = 12345 # Tells swarm that the node is going to output final images
VIDEO_ID = 12346
@@ -43,9 +42,8 @@ class SwarmSaveImageWS:
def convert_opencv_to_pil(self, img_np):
try:
# Convert BGR to RGB
import cv2
img_np = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
_, img_encoded = cv2.imencode('.png', img_np)
if img_encoded is None:
@@ -54,9 +52,7 @@ class SwarmSaveImageWS:
img_bytes = io.BytesIO(img_encoded.tobytes())
img = Image.open(img_bytes)
img = img.convert('RGB')
return img
except Exception as e:
print(f"Error converting OpenCV image to PIL: {e}")
raise

View File

@@ -428,11 +428,10 @@ public class WorkflowGenerator
{
if (Features.Contains("comfy_saveimage_ws") && !RestrictCustomNodes)
{
string bitDepth = UserInput.Get(T2IParamTypes.BitDepth, "8bit");
return CreateNode("SwarmSaveImageWS", new JObject()
{
["images"] = image,
["bit_depth"] = bitDepth
["bit_depth"] = UserInput.Get(T2IParamTypes.BitDepth, "8bit")
}, id);
}
else

View File

@@ -12,3 +12,4 @@
[assembly: SuppressMessage("Performance", "CA1860:Avoid using 'Enumerable.Any()' extension method")]
[assembly: SuppressMessage("Usage", "ASP0018:Unused route parameter")]
[assembly: SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments")]
[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "Extensions have intentional mismatch")]

View File

@@ -575,15 +575,15 @@ public class T2IParamTypes
return s;
}
));
BitDepth = Register<string>(new("Color Depth", "Specifies the color depth for PNG format:\n- 8-bit per channel (24-bit total)\n- 16-bit per channel (48-bit total)\n\nOther formats ignore this setting.",
"8bit", GetValues: (_) => ["8bit///8-bit per channel (24-bit total)", "16bit///16-bit per channel (48-bit total)"], IsAdvanced: true, Toggleable: true, Group: GroupSwarmInternal, OrderPriority: 3
));
PersonalNote = Register<string>(new("Personal Note", "Optional field to type in any personal text note you want.\nThis will be stored in the image metadata.",
"", IgnoreIf: "", IsAdvanced: true, Group: GroupSwarmInternal, ViewType: ParamViewType.BIG, AlwaysRetain: true, OrderPriority: 0
));
ImageFormat = Register<string>(new("Image Format", "Optional override for the final image file format.",
"PNG", GetValues: (_) => [.. Enum.GetNames(typeof(Image.ImageFormat))], IsAdvanced: true, Group: GroupSwarmInternal, AlwaysRetain: true, Toggleable: true, OrderPriority: 1
));
BitDepth = Register<string>(new("Color Depth", "Specifies the color depth for PNG format:\n- 8-bit per channel (24-bit total)\n- 16-bit per channel (48-bit total)\n\nOther formats ignore this setting.",
"8bit", GetValues: (_) => ["8bit///8-bit per channel (24-bit total)", "16bit///16-bit per channel (48-bit total)"], IsAdvanced: true, Toggleable: true, Group: GroupSwarmInternal, OrderPriority: 1.5
));
ModelSpecificEnhancements = Register<bool>(new("Model Specific Enhancements", "If checked, enables model-specific enhancements.\nFor example, on SDXL, smarter res-cond will be used.\nIf unchecked, will prefer more 'raw' behavior.",
"true", IgnoreIf: "true", IsAdvanced: true, Group: GroupSwarmInternal, OrderPriority: 2
));