parameter-adjustment

This commit is contained in:
wTechArtist
2024-11-08 20:35:48 +08:00
parent c5ab5be930
commit 4fc2b312ba
+12 -63
View File
@@ -6,7 +6,8 @@ import folder_paths
from .stabledelight_comfyui.pipeline_yoso_delight import YosoDelightPipeline
class StableDelightNode:
upscale_methods = ["bilinear", "nearest-exact", "area", "bicubic"]
resample_methods = ["bilinear","nearest", "nearest-exact", "bicubic", "area"]
@classmethod
def INPUT_TYPES(s):
return {
@@ -18,35 +19,13 @@ class StableDelightNode:
"max": 4096,
"step": 64
}),
"t_start": ("FLOAT", {
"default": 0.0,
"resample_method": (s.resample_methods,),
"controlnet_conditioning_scale": ("FLOAT", {
"default": 1.0,
"min": 0.0,
"max": 1.0,
"step": 0.01
"max": 10.0,
"step": 0.1
}),
"match_input_resolution": ("BOOLEAN", {
"default": False
}),
"ensemble_size": ("INT", {
"default": 1,
"min": 1,
"max": 10,
"step": 1
}),
"batch_size": ("INT", {
"default": 1,
"min": 1,
"max": 4,
"step": 1
}),
},
"optional": {
"seed": ("INT", {
"default": -1,
"min": -1,
"max": 0xffffffffffffffff
}),
"resample_method": (s.upscale_methods,),
}
}
@@ -69,34 +48,8 @@ class StableDelightNode:
except:
pass
def resize_image(self, input_image, resolution):
# Convert tensor to PIL Image
if torch.is_tensor(input_image):
if input_image.ndim == 4:
input_image = input_image[0]
input_image = (input_image * 255).clamp(0, 255).to(torch.uint8)
input_image = Image.fromarray(input_image.cpu().numpy())
# Get image dimensions
W, H = input_image.size
k = float(resolution) / min(H, W)
H *= k
W *= k
H = int(np.round(H / 64.0)) * 64
W = int(np.round(W / 64.0)) * 64
# Resize the image
return input_image.resize((W, H), Image.Resampling.LANCZOS)
def delight_image(self, image, processing_resolution, t_start, match_input_resolution,
ensemble_size, batch_size, seed=-1, resample_method="lanczos"):
# Set random seed if provided
if seed != -1:
generator = torch.Generator(device=self.device).manual_seed(seed)
else:
generator = None
# Convert from ComfyUI image format to PIL and resize
def delight_image(self, image, processing_resolution, resample_method, controlnet_conditioning_scale):
# Convert from ComfyUI image format to PIL
if torch.is_tensor(image):
if image.ndim == 4:
image = image[0]
@@ -106,14 +59,10 @@ class StableDelightNode:
# Process image
pipe_out = self.pipe(
image,
match_input_resolution=match_input_resolution,
processing_resolution=processing_resolution,
t_start=t_start,
ensemble_size=ensemble_size,
batch_size=batch_size,
generator=generator,
resample_method_input=resample_method,
resample_method_output=resample_method
resample_method_output=resample_method,
controlnet_conditioning_scale=controlnet_conditioning_scale
)
# Convert output to ComfyUI format
@@ -126,4 +75,4 @@ class StableDelightNode:
if processed.ndim == 3:
processed = processed.unsqueeze(0)
return (processed,)
return (processed,)