diff --git a/comfy_extras/nodes_qwen.py b/comfy_extras/nodes_qwen.py index c7e9fdecc..afba40069 100644 --- a/comfy_extras/nodes_qwen.py +++ b/comfy_extras/nodes_qwen.py @@ -29,19 +29,16 @@ class TextEncodeQwenImageEdit: total = int(1024 * 1024) scale_by = math.sqrt(total / (samples.shape[3] * samples.shape[2])) - # 修改缩放规则:乘数为8,向下取整 + width = math.floor(samples.shape[3] * scale_by / 8) * 8 height = math.floor(samples.shape[2] * scale_by / 8) * 8 - # 根据缩放比例选择算法:缩小用area,放大用lanczos original_width = samples.shape[3] original_height = samples.shape[2] if width < original_width or height < original_height: - # 缩小图像,使用area算法保持细节 upscale_method = "area" else: - # 放大图像,使用lanczos算法获得更好质量 upscale_method = "lanczos" s = comfy.utils.common_upscale(samples, width, height, upscale_method, "disabled") @@ -57,7 +54,6 @@ class TextEncodeQwenImageEdit: if ref_latent is not None: conditioning = node_helpers.conditioning_set_values(conditioning, {"reference_latents": [ref_latent]}, append=True) - # 将ref_latent包装成ComfyUI LATENT类型要求的格式 latent_output = {"samples": ref_latent} if ref_latent is not None else None return (conditioning, output_image, latent_output)