mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-08 00:27:07 +08:00
Fix: Kling image gen nodes don't return entire batch when n > 1 (#152)
This commit is contained in:
parent
adc6067ca7
commit
79f098187f
@ -225,13 +225,16 @@ def video_result_to_node_output(
|
|||||||
|
|
||||||
|
|
||||||
def image_result_to_node_output(
|
def image_result_to_node_output(
|
||||||
image: KlingImageResult,
|
images: list[KlingImageResult],
|
||||||
) -> torch.Tensor:
|
) -> torch.Tensor:
|
||||||
"""
|
"""
|
||||||
Converts a KlingImageResult to a tuple containing a [B, H, W, C] tensor.
|
Converts a KlingImageResult to a tuple containing a [B, H, W, C] tensor.
|
||||||
If multiple images are returned, they will be stacked along the batch dimension.
|
If multiple images are returned, they will be stacked along the batch dimension.
|
||||||
"""
|
"""
|
||||||
return (download_url_to_image_tensor(image.url),)
|
if len(images) == 1:
|
||||||
|
return download_url_to_image_tensor(images[0].url)
|
||||||
|
else:
|
||||||
|
return torch.cat([download_url_to_image_tensor(image.url) for image in images])
|
||||||
|
|
||||||
|
|
||||||
class KlingNodeBase(ComfyNodeABC):
|
class KlingNodeBase(ComfyNodeABC):
|
||||||
@ -1384,8 +1387,8 @@ class KlingVirtualTryOnNode(KlingImageGenerationBase):
|
|||||||
final_response = self.get_response(task_id, auth_token)
|
final_response = self.get_response(task_id, auth_token)
|
||||||
validate_image_result_response(final_response)
|
validate_image_result_response(final_response)
|
||||||
|
|
||||||
image = get_images_from_response(final_response)
|
images = get_images_from_response(final_response)
|
||||||
return image_result_to_node_output(image)
|
return image_result_to_node_output(images)
|
||||||
|
|
||||||
|
|
||||||
class KlingImageGenerationNode(KlingImageGenerationBase):
|
class KlingImageGenerationNode(KlingImageGenerationBase):
|
||||||
@ -1513,8 +1516,8 @@ class KlingImageGenerationNode(KlingImageGenerationBase):
|
|||||||
final_response = self.get_response(task_id, auth_token)
|
final_response = self.get_response(task_id, auth_token)
|
||||||
validate_image_result_response(final_response)
|
validate_image_result_response(final_response)
|
||||||
|
|
||||||
image = get_images_from_response(final_response)
|
images = get_images_from_response(final_response)
|
||||||
return image_result_to_node_output(image)
|
return image_result_to_node_output(images)
|
||||||
|
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user