diff --git a/nodes/shot_by_image_automatic_node.py b/nodes/shot_by_image_automatic_node.py index 66f2181..4c405a5 100644 --- a/nodes/shot_by_image_automatic_node.py +++ b/nodes/shot_by_image_automatic_node.py @@ -8,8 +8,16 @@ class ShotByImageAutomaticNode: input_types["required"]["shot_size"] = ("STRING", {"default": "1000, 1000"}) return input_types - RETURN_TYPES = ("IMAGE",) - RETURN_NAMES = ("output_image",) + RETURN_TYPES = ("IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE") + RETURN_NAMES = ( + "output_image_1", + "output_image_2", + "output_image_3", + "output_image_4", + "output_image_5", + "output_image_6", + "output_image_7", + ) CATEGORY = "API Nodes" FUNCTION = "execute" @@ -40,4 +48,4 @@ class ShotByImageAutomaticNode: force_rmbg=force_rmbg, content_moderation=content_moderation, ) - return make_api_request(self.api_url, payload, api_key) + return make_api_request(self.api_url, payload, api_key, Placement_type = PlacementType.AUTOMATIC.value) diff --git a/nodes/shot_by_text_automatic_node.py b/nodes/shot_by_text_automatic_node.py index 13ce3e7..20371f0 100644 --- a/nodes/shot_by_text_automatic_node.py +++ b/nodes/shot_by_text_automatic_node.py @@ -8,8 +8,16 @@ class ShotByTextAutomaticNode: input_types["required"]["shot_size"] = ("STRING", {"default": "1000, 1000"}) return input_types - RETURN_TYPES = ("IMAGE",) - RETURN_NAMES = ("output_image",) + RETURN_TYPES = ("IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE", "IMAGE") + RETURN_NAMES = ( + "output_image_1", + "output_image_2", + "output_image_3", + "output_image_4", + "output_image_5", + "output_image_6", + "output_image_7", + ) CATEGORY = "API Nodes" FUNCTION = "execute" @@ -42,4 +50,4 @@ class ShotByTextAutomaticNode: force_rmbg=force_rmbg, content_moderation=content_moderation, ) - return make_api_request(self.api_url, payload, api_key) + return make_api_request(self.api_url, payload, api_key, Placement_type= PlacementType.AUTOMATIC.value) diff --git a/nodes/utils/shot_utils.py b/nodes/utils/shot_utils.py index 21b4765..bcdda1a 100644 --- a/nodes/utils/shot_utils.py +++ b/nodes/utils/shot_utils.py @@ -124,7 +124,7 @@ def create_image_payload(image, ref_image, api_key, placement_type, **kwargs): return payload -def make_api_request(api_url, payload, api_key): +def make_api_request(api_url, payload, api_key, Placement_type = None): """Make API request and return processed image""" headers = {"Content-Type": "application/json", "api_token": f"{api_key}"} @@ -134,6 +134,21 @@ def make_api_request(api_url, payload, api_key): if response.status_code == 200: print("response is 200") response_dict = response.json() + if Placement_type == PlacementType.AUTOMATIC.value: + result_images = [] + for i, result in enumerate(response_dict.get("result", [])[:7]): + image_url = result[0] + image_response = requests.get(image_url) + processed = postprocess_image(image_response.content) + result_images.append(processed) + + # If less than 7 images, pad with None to match ComfyUI return structure + while len(result_images) < 7: + result_images.append(None) + print(result_images) + + return tuple(result_images) + image_response = requests.get(response_dict["result"][0][0]) result_image = postprocess_image(image_response.content) return (result_image,)