Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

convert nodes_stability.py to V3 schema (#9497)

Alexander Piskund2c502e629ba
diff --git a/comfy_api_nodes/nodes_stability.py b/comfy_api_nodes/nodes_stability.py
index 31309d831..e05cb6bb2 100644
--- a/comfy_api_nodes/nodes_stability.py
+++ b/comfy_api_nodes/nodes_stability.py
@@ -1,5 +1,8 @@
from inspect import cleandoc
-from comfy.comfy_types.node_typing import IO
+from typing import Optional
+from typing_extensions import override
+
+from comfy_api.latest import ComfyExtension, io as comfy_io
from comfy_api_nodes.apis.stability_api import (
StabilityUpscaleConservativeRequest,
StabilityUpscaleCreativeRequest,
@@ -46,87 +49,94 @@ def get_async_dummy_status(x: StabilityResultsGetResponse):
return StabilityPollStatus.in_progress
-class StabilityStableImageUltraNode:
+class StabilityStableImageUltraNode(comfy_io.ComfyNode):
"""
Generates images synchronously based on prompt and resolution.
"""
- RETURN_TYPES = (IO.IMAGE,)
- DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
- FUNCTION = "api_call"
- API_NODE = True
- CATEGORY = "api node/image/Stability AI"
-
@classmethod
- def INPUT_TYPES(s):
- return {
- "required": {
- "prompt": (
- IO.STRING,
- {
- "multiline": True,
- "default": "",
- "tooltip": "What you wish to see in the output image. A strong, descriptive prompt that clearly defines" +
- "What you wish to see in the output image. A strong, descriptive prompt that clearly defines" +
+ def define_schema(cls):
+ return comfy_io.Schema(
+ node_id="StabilityStableImageUltraNode",
+ display_name="Stability AI Stable Image Ultra",
+ category="api node/image/Stability AI",
+ description=cleandoc(cls.__doc__ or ""),
+ inputs=[
+ comfy_io.String.Input(
+ "prompt",
+ multiline=True,
+ default="",
+ tooltip="What you wish to see in the output image. A strong, descriptive prompt that clearly defines" +
"elements, colors, and subjects will lead to better results. " +
"To control the weight of a given word use the format `(word:weight)`," +
"where `word` is the word you'd like to control the weight of and `weight`" +
"is a value between 0 and 1. For example: `The sky was a crisp (blue:0.3) and (green:0.8)`" +
- "would convey a sky that was blue and green, but more green than blue."
- },
+ "would convey a sky that was blue and green, but more green than blue.",
),
- "aspect_ratio": ([x.value for x in StabilityAspectRatio],
- {
- "default": StabilityAspectRatio.ratio_1_1,
- "tooltip": "Aspect ratio of generated image.",
- },
+ comfy_io.Combo.Input(
+ "aspect_ratio",
+ options=[x.value for x in StabilityAspectRatio],
+ default=StabilityAspectRatio.ratio_1_1.value,
+ tooltip="Aspect ratio of generated image.",
),
- "style_preset": (get_stability_style_presets(),
- {
- "tooltip": "Optional desired style of generated image.",
- },
+ comfy_io.Combo.Input(
+ "style_preset",
+ options=get_stability_style_presets(),
+ tooltip="Optional desired style of generated image.",
),
- "seed": (
- IO.INT,
- {
- "default": 0,
- "min": 0,
- "max": 4294967294,
- "control_after_generate": True,
- "tooltip": "The random seed used for creating the noise.",
- },
+ comfy_io.Int.Input(
+ "seed",
+ default=0,
+ min=0,
+ max=4294967294,
+ step=1,
+ display_mode=comfy_io.NumberDisplay.number,
+ control_after_generate=True,
+ tooltip="The random seed used for creating the noise.",
),
- },
- "optional": {
- "image": (IO.IMAGE,),
- "negative_prompt": (
- IO.STRING,
- {
- "default": "",
- "forceInput": True,
- "tooltip": "A blurb of text describing what you do not wish to see in the output image. This is an advanced feature."
- },
+ comfy_io.Image.Input(
+ "image",
+ optional=True,
),
- "image_denoise": (
- IO.FLOAT,
- {
- "default": 0.5,
- "min": 0.0,
- "max": 1.0,
- "step": 0.01,
- "tooltip": "Denoise of input image; 0.0 yields image identical to input, 1.0 is as if no image was provided at all.",
- },
+ comfy_io.String.Input(
+ "negative_prompt",
+ default="",
+ tooltip="A blurb of text describing what you do not wish to see in the output image. This is an advanced feature.",
+ force_input=True,
+ optional=True,
),
- },
- "hidden": {
- "auth_token": "AUTH_TOKEN_COMFY_ORG",
- "comfy_api_key": "API_KEY_COMFY_ORG",
- },
- }
+ comfy_io.Float.Input(
+ "image_denoise",
+ default=0.5,
+ min=0.0,
+ max=1.0,
+ step=0.01,
+ tooltip="Denoise of input image; 0.0 yields image identical to input, 1.0 is as if no image was provided at all.",
+ optional=True,
+ ),
+ ],
+ outputs=[
+ comfy_io.Image.Output(),
+ ],
+ hidden=[
+ comfy_io.Hidden.auth_token_comfy_org,
+ comfy_io.Hidden.api_key_comfy_org,
+ comfy_io.Hidden.unique_id,
+ ],
+ is_api_node=True,
+ )
- async def api_call(self, prompt: str, aspect_ratio: str, style_preset: str, seed: int,
- negative_prompt: str=None, image: torch.Tensor = None, image_denoise: float=None,
- **kwargs):
+ @classmethod
+ async def execute(
+ cls,
+ prompt: str,
+ aspect_ratio: str,
+ style_preset: str,
+ seed: int,
+ image: Optional[torch.Tensor] = None,
+ negative_prompt: str = "",
+ image_denoise: Optional[float] = 0.5,
+ ) -> comfy_io.NodeOutput:
validate_string(prompt, strip_whitespace=False)
# prepare image binary if image present
image_binary = None
@@ -144,6 +154,11 @@ class StabilityStableImageUltraNode:
"image": image_binary
}
+ auth = {
+ "auth_token": cls.hidden.auth_token_comfy_org,
+ "comfy_api_key": cls.hidden.api_key_comfy_org,
+ }
+
operation = SynchronousOperation(
endpoint=ApiEndpoint(
path="/proxy/stability/v2beta/stable-image/generate/ultra",
@@ -161,7 +176,7 @@ class StabilityStableImageUltraNode:
),
files=files,
content_type="multipart/form-data",
- auth_kwargs=kwargs,
+ auth_kwargs=auth,
)
response_api = await operation.execute()
@@ -171,95 +186,106 @@ class StabilityStableImageUltraNode:
image_data = base64.b64decode(response_api.image)
returned_image = bytesio_to_image_tensor(BytesIO(image_data))
- return (returned_image,)
+ return comfy_io.NodeOutput(returned_image)
-class StabilityStableImageSD_3_5Node:
+class StabilityStableImageSD_3_5Node(comfy_io.ComfyNode):
"""
Generates images synchronously based on prompt and resolution.
"""
- RETURN_TYPES = (IO.IMAGE,)
- DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
- FUNCTION = "api_call"
- API_NODE = True
- CATEGORY = "api node/image/Stability AI"
-
@classmethod
- def INPUT_TYPES(s):
- return {
- "required": {
- "prompt": (
- IO.STRING,
- {
- "multiline": True,
- "default": "",
- "tooltip": "What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results."
- },
+ def define_schema(cls):
+ return comfy_io.Schema(
+ node_id="StabilityStableImageSD_3_5Node",
+ display_name="Stability AI Stable Diffusion 3.5 Image",
+ category="api node/image/Stability AI",
+ description=cleandoc(cls.__doc__ or ""),
+ inputs=[
+ comfy_io.String.Input(
+ "prompt",
+ multiline=True,
+ default="",
+ tooltip="What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.",
),
- "model": ([x.value for x in Stability_SD3_5_Model],),
- "aspect_ratio": ([x.value for x in StabilityAspectRatio],
- {
- "default": StabilityAspectRatio.ratio_1_1,
- "tooltip": "Aspect ratio of generated image.",
- },
+ comfy_io.Combo.Input(
+ "model",
+ options=[x.value for x in Stability_SD3_5_Model],
),
- "style_preset": (get_stability_style_presets(),
- {
- "tooltip": "Optional desired style of generated image.",
- },
+ comfy_io.Combo.Input(
+ "aspect_ratio",
+ options=[x.value for x in StabilityAspectRatio],
+ default=StabilityAspectRatio.ratio_1_1.value,
+ tooltip="Aspect ratio of generated image.",
),
- "cfg_scale": (
- IO.FLOAT,
- {
- "default": 4.0,
- "min": 1.0,
- "max": 10.0,
- "step": 0.1,
- "tooltip": "How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)",
- },
+ comfy_io.Combo.Input(
+ "style_preset",
+ options=get_stability_style_presets(),
+ tooltip="Optional desired style of generated image.",
),
- "seed": (
- IO.INT,
- {
- "default": 0,
- "min": 0,
- "max": 4294967294,
- "control_after_generate": True,
- "tooltip": "The random seed used for creating the noise.",
- },
+ comfy_io.Float.Input(
+ "cfg_scale",
+ default=4.0,
+ min=1.0,
+ max=10.0,
+ step=0.1,
+ tooltip="How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)",
),
- },
- "optional": {
- "image": (IO.IMAGE,),
- "negative_prompt": (
- IO.STRING,
- {
- "default": "",
- "forceInput": True,
- "tooltip": "Keywords of what you do not wish to see in the output image. This is an advanced feature."
- },
+ comfy_io.Int.Input(
+ "seed",
+ default=0,
+ min=0,
+ max=4294967294,
+ step=1,
+ display_mode=comfy_io.NumberDisplay.number,
+ control_after_generate=True,
+ tooltip="The random seed used for creating the noise.",
),
- "image_denoise": (
- IO.FLOAT,
- {
- "default": 0.5,
- "min": 0.0,
- "max": 1.0,
- "step": 0.01,
- "tooltip": "Denoise of input image; 0.0 yields image identical to input, 1.0 is as if no image was provided at all.",
- },
+ comfy_io.Image.Input(
+ "image",
+ optional=True,
),
- },
- "hidden": {
- "auth_token": "AUTH_TOKEN_COMFY_ORG",
- "comfy_api_key": "API_KEY_COMFY_ORG",
- },
- }
+ comfy_io.String.Input(
+ "negative_prompt",
+ default="",
+ tooltip="Keywords of what you do not wish to see in the output image. This is an advanced feature.",
+ force_input=True,
+ optional=True,
+ ),
+ comfy_io.Float.Input(
+ "image_denoise",
+ default=0.5,
+ min=0.0,
+ max=1.0,
+ step=0.01,
+ tooltip="Denoise of input image; 0.0 yields image identical to input, 1.0 is as if no image was provided at all.",
+ optional=True,
+ ),
+ ],
+ outputs=[
+ comfy_io.Image.Output(),
+ ],
+ hidden=[
+ comfy_io.Hidden.auth_token_comfy_org,
+ comfy_io.Hidden.api_key_comfy_org,
+ comfy_io.Hidden.unique_id,
+ ],
+ is_api_node=True,
+ )
- async def api_call(self, model: str, prompt: str, aspect_ratio: str, style_preset: str, seed: int, cfg_scale: float,
- negative_prompt: str=None, image: torch.Tensor = None, image_denoise: float=None,
- **kwargs):
+ @classmethod
+ async def execute(
+ cls,
+ model: str,
+ prompt: str,
+ aspect_ratio: str,
+ style_preset: str,
+ seed: int,
+ cfg_scale: float,
+ image: Optional[torch.Tensor] = None,
+ negative_prompt: str = "",
+ image_denoise: Optional[float] = 0.5,
+ ) -> comfy_io.NodeOutput:
validate_string(prompt, strip_whitespace=False)
# prepare image binary if image present
image_binary = None
@@ -280,6 +306,11 @@ class StabilityStableImageSD_3_5Node:
"image": image_binary
}
+ auth = {
+ "auth_token": cls.hidden.auth_token_comfy_org,
+ "comfy_api_key": cls.hidden.api_key_comfy_org,
+ }
+
operation = SynchronousOperation(
endpoint=ApiEndpoint(
path="/proxy/stability/v2beta/stable-image/generate/sd3",
@@ -300,7 +331,7 @@ class StabilityStableImageSD_3_5Node:
),
files=files,
content_type="multipart/form-data",
- auth_kwargs=kwargs,
+ auth_kwargs=auth,
)
response_api = await operation.execute()
@@ -310,72 +341,75 @@ class StabilityStableImageSD_3_5Node:
image_data = base64.b64decode(response_api.image)
returned_image = bytesio_to_image_tensor(BytesIO(image_data))
- return (returned_image,)
+ return comfy_io.NodeOutput(returned_image)
-class StabilityUpscaleConservativeNode:
+class StabilityUpscaleConservativeNode(comfy_io.ComfyNode):
"""
Upscale image with minimal alterations to 4K resolution.
"""
- RETURN_TYPES = (IO.IMAGE,)
- DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
- FUNCTION = "api_call"
- API_NODE = True
- CATEGORY = "api node/image/Stability AI"
-
@classmethod
- def INPUT_TYPES(s):
- return {
- "required": {
- "image": (IO.IMAGE,),
- "prompt": (
- IO.STRING,
- {
- "multiline": True,
- "default": "",
- "tooltip": "What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results."
- },
+ def define_schema(cls):
+ return comfy_io.Schema(
+ node_id="StabilityUpscaleConservativeNode",
+ display_name="Stability AI Upscale Conservative",
+ category="api node/image/Stability AI",
+ description=cleandoc(cls.__doc__ or ""),
+ inputs=[
+ comfy_io.Image.Input("image"),
+ comfy_io.String.Input(
+ "prompt",
+ multiline=True,
+ default="",
+ tooltip="What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.",
),
- "creativity": (
- IO.FLOAT,
- {
- "default": 0.35,
- "min": 0.2,
- "max": 0.5,
- "step": 0.01,
- "tooltip": "Controls the likelihood of creating additional details not heavily conditioned by the init image.",
- },
+ comfy_io.Float.Input(
+ "creativity",
+ default=0.35,
+ min=0.2,
+ max=0.5,
+ step=0.01,
+ tooltip="Controls the likelihood of creating additional details not heavily conditioned by the init image.",
),
- "seed": (
- IO.INT,
- {
- "default": 0,
- "min": 0,
- "max": 4294967294,
- "control_after_generate": True,
- "tooltip": "The random seed used for creating the noise.",
- },
+ comfy_io.Int.Input(
+ "seed",
+ default=0,
+ min=0,
+ max=4294967294,
+ step=1,
+ display_mode=comfy_io.NumberDisplay.number,
+ control_after_generate=True,
+ tooltip="The random seed used for creating the noise.",
),
- },
- "optional": {
- "negative_prompt": (
- IO.STRING,
- {
- "default": "",
- "forceInput": True,
- "tooltip": "Keywords of what you do not wish to see in the output image. This is an advanced feature."
- },
+ comfy_io.String.Input(
+ "negative_prompt",
+ default="",
+ tooltip="Keywords of what you do not wish to see in the output image. This is an advanced feature.",
+ force_input=True,
+ optional=True,
),
- },
- "hidden": {
- "auth_token": "AUTH_TOKEN_COMFY_ORG",
- "comfy_api_key": "API_KEY_COMFY_ORG",
- },
- }
+ ],
+ outputs=[
+ comfy_io.Image.Output(),
+ ],
+ hidden=[
+ comfy_io.Hidden.auth_token_comfy_org,
+ comfy_io.Hidden.api_key_comfy_org,
+ comfy_io.Hidden.unique_id,
+ ],
+ is_api_node=True,
+ )
- async def api_call(self, image: torch.Tensor, prompt: str, creativity: float, seed: int, negative_prompt: str=None,
- **kwargs):
+ @classmethod
+ async def execute(
+ cls,
+ image: torch.Tensor,
+ prompt: str,
+ creativity: float,
+ seed: int,
+ negative_prompt: str = "",
+ ) -> comfy_io.NodeOutput:
validate_string(prompt, strip_whitespace=False)
image_binary = tensor_to_bytesio(image, total_pixels=1024*1024).read()
@@ -386,6 +420,11 @@ class StabilityUpscaleConservativeNode:
"image": image_binary
}
+ auth = {
+ "auth_token": cls.hidden.auth_token_comfy_org,
+ "comfy_api_key": cls.hidden.api_key_comfy_org,
+ }
+
operation = SynchronousOperation(
endpoint=ApiEndpoint(
path="/proxy/stability/v2beta/stable-image/upscale/conservative",
@@ -401,7 +440,7 @@ class StabilityUpscaleConservativeNode:
),
files=files,
content_type="multipart/form-data",
- auth_kwargs=kwargs,
+ auth_kwargs=auth,
)
response_api = await operation.execute()
@@ -411,77 +450,81 @@ class StabilityUpscaleConservativeNode:
image_data = base64.b64decode(response_api.image)
returned_image = bytesio_to_image_tensor(BytesIO(image_data))
- return (returned_image,)
+ return comfy_io.NodeOutput(returned_image)
-class StabilityUpscaleCreativeNode:
+class StabilityUpscaleCreativeNode(comfy_io.ComfyNode):
"""
Upscale image with minimal alterations to 4K resolution.
"""
- RETURN_TYPES = (IO.IMAGE,)
- DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
- FUNCTION = "api_call"
- API_NODE = True
- CATEGORY = "api node/image/Stability AI"
-
@classmethod
- def INPUT_TYPES(s):
- return {
- "required": {
- "image": (IO.IMAGE,),
- "prompt": (
- IO.STRING,
- {
- "multiline": True,
- "default": "",
- "tooltip": "What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results."
- },
+ def define_schema(cls):
+ return comfy_io.Schema(
+ node_id="StabilityUpscaleCreativeNode",
+ display_name="Stability AI Upscale Creative",
+ category="api node/image/Stability AI",
+ description=cleandoc(cls.__doc__ or ""),
+ inputs=[
+ comfy_io.Image.Input("image"),
+ comfy_io.String.Input(
+ "prompt",
+ multiline=True,
+ default="",
+ tooltip="What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.",
),
- "creativity": (
- IO.FLOAT,
- {
- "default": 0.3,
- "min": 0.1,
- "max": 0.5,
- "step": 0.01,
- "tooltip": "Controls the likelihood of creating additional details not heavily conditioned by the init image.",
- },
+ comfy_io.Float.Input(
+ "creativity",
+ default=0.3,
+ min=0.1,
+ max=0.5,
+ step=0.01,
+ tooltip="Controls the likelihood of creating additional details not heavily conditioned by the init image.",
),
- "style_preset": (get_stability_style_presets(),
- {
- "tooltip": "Optional desired style of generated image.",
- },
+ comfy_io.Combo.Input(
+ "style_preset",
+ options=get_stability_style_presets(),
+ tooltip="Optional desired style of generated image.",
),
- "seed": (
- IO.INT,
- {
- "default": 0,
- "min": 0,
- "max": 4294967294,
- "control_after_generate": True,
- "tooltip": "The random seed used for creating the noise.",
- },
+ comfy_io.Int.Input(
+ "seed",
+ default=0,
+ min=0,
+ max=4294967294,
+ step=1,
+ display_mode=comfy_io.NumberDisplay.number,
+ control_after_generate=True,
+ tooltip="The random seed used for creating the noise.",
),
- },
- "optional": {
- "negative_prompt": (
- IO.STRING,
- {
- "default": "",
- "forceInput": True,
- "tooltip": "Keywords of what you do not wish to see in the output image. This is an advanced feature."
- },
+ comfy_io.String.Input(
+ "negative_prompt",
+ default="",
+ tooltip="Keywords of what you do not wish to see in the output image. This is an advanced feature.",
+ force_input=True,
+ optional=True,
),
- },
- "hidden": {
- "auth_token": "AUTH_TOKEN_COMFY_ORG",
- "comfy_api_key": "API_KEY_COMFY_ORG",
- },
- }
+ ],
+ outputs=[
+ comfy_io.Image.Output(),
+ ],
+ hidden=[
+ comfy_io.Hidden.auth_token_comfy_org,
+ comfy_io.Hidden.api_key_comfy_org,
+ comfy_io.Hidden.unique_id,
+ ],
+ is_api_node=True,
+ )
- async def api_call(self, image: torch.Tensor, prompt: str, creativity: float, style_preset: str, seed: int, negative_prompt: str=None,
- **kwargs):
+ @classmethod
+ async def execute(
+ cls,
+ image: torch.Tensor,
+ prompt: str,
+ creativity: float,
+ style_preset: str,
+ seed: int,
+ negative_prompt: str = "",
+ ) -> comfy_io.NodeOutput:
validate_string(prompt, strip_whitespace=False)
image_binary = tensor_to_bytesio(image, total_pixels=1024*1024).read()
@@ -494,6 +537,11 @@ class StabilityUpscaleCreativeNode:
"image": image_binary
}
+ auth = {
+ "auth_token": cls.hidden.auth_token_comfy_org,
+ "comfy_api_key": cls.hidden.api_key_comfy_org,
+ }
+
operation = SynchronousOperation(
endpoint=ApiEndpoint(
path="/proxy/stability/v2beta/stable-image/upscale/creative",
@@ -510,7 +558,7 @@ class StabilityUpscaleCreativeNode:
),
files=files,
content_type="multipart/form-data",
- auth_kwargs=kwargs,
+ auth_kwargs=auth,
)
response_api = await operation.execute()
@@ -525,7 +573,8 @@ class StabilityUpscaleCreativeNode:
completed_statuses=[StabilityPollStatus.finished],
failed_statuses=[StabilityPollStatus.failed],
status_extractor=lambda x: get_async_dummy_status(x),
- auth_kwargs=kwargs,
+ auth_kwargs=auth,
+ node_id=cls.hidden.unique_id,
)
response_poll: StabilityResultsGetResponse = await operation.execute()
@@ -535,41 +584,48 @@ class StabilityUpscaleCreativeNode:
image_data = base64.b64decode(response_poll.result)
returned_image = bytesio_to_image_tensor(BytesIO(image_data))
- return (returned_image,)
+ return comfy_io.NodeOutput(returned_image)
-class StabilityUpscaleFastNode:
+class StabilityUpscaleFastNode(comfy_io.ComfyNode):
"""
Quickly upscales an image via Stability API call to 4x its original size; intended for upscaling low-quality/compressed images.
"""
- RETURN_TYPES = (IO.IMAGE,)
- DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
- FUNCTION = "api_call"
- API_NODE = True
- CATEGORY = "api node/image/Stability AI"
-
@classmethod
- def INPUT_TYPES(s):
- return {
- "required": {
- "image": (IO.IMAGE,),
- },
- "optional": {
- },
- "hidden": {
- "auth_token": "AUTH_TOKEN_COMFY_ORG",
- "comfy_api_key": "API_KEY_COMFY_ORG",
- },
- }
+ def define_schema(cls):
+ return comfy_io.Schema(
+ node_id="StabilityUpscaleFastNode",
+ display_name="Stability AI Upscale Fast",
+ category="api node/image/Stability AI",
+ description=cleandoc(cls.__doc__ or ""),
+ inputs=[
+ comfy_io.Image.Input("image"),
+ ],
+ outputs=[
+ comfy_io.Image.Output(),
+ ],
+ hidden=[
+ comfy_io.Hidden.auth_token_comfy_org,
+ comfy_io.Hidden.api_key_comfy_org,
+ comfy_io.Hidden.unique_id,
+ ],
+ is_api_node=True,
+ )
- async def api_call(self, image: torch.Tensor, **kwargs):
+ @classmethod
+ async def execute(cls, image: torch.Tensor) -> comfy_io.NodeOutput:
image_binary = tensor_to_bytesio(image, total_pixels=4096*4096).read()
files = {
"image": image_binary
}
+ auth = {
+ "auth_token": cls.hidden.auth_token_comfy_org,
+ "comfy_api_key": cls.hidden.api_key_comfy_org,
+ }
+
operation = SynchronousOperation(
endpoint=ApiEndpoint(
path="/proxy/stability/v2beta/stable-image/upscale/fast",
@@ -580,7 +636,7 @@ class StabilityUpscaleFastNode:
request=EmptyRequest(),
files=files,
content_type="multipart/form-data",
- auth_kwargs=kwargs,
+ auth_kwargs=auth,
)
response_api = await operation.execute()
@@ -590,24 +646,20 @@ class StabilityUpscaleFastNode:
image_data = base64.b64decode(response_api.image)
returned_image = bytesio_to_image_tensor(BytesIO(image_data))
- return (returned_image,)
-
-
-# A dictionary that contains all nodes you want to export with their names
-# NOTE: names should be globally unique
-NODE_CLASS_MAPPINGS = {
- "StabilityStableImageUltraNode": StabilityStableImageUltraNode,
- "StabilityStableImageSD_3_5Node": StabilityStableImageSD_3_5Node,
- "StabilityUpscaleConservativeNode": StabilityUpscaleConservativeNode,
- "StabilityUpscaleCreativeNode": StabilityUpscaleCreativeNode,
- "StabilityUpscaleFastNode": StabilityUpscaleFastNode,
-}
-
-# A dictionary that contains the friendly/humanly readable titles for the nodes
-NODE_DISPLAY_NAME_MAPPINGS = {
- "StabilityStableImageUltraNode": "Stability AI Stable Image Ultra",
- "StabilityStableImageSD_3_5Node": "Stability AI Stable Diffusion 3.5 Image",
- "StabilityUpscaleConservativeNode": "Stability AI Upscale Conservative",
- "StabilityUpscaleCreativeNode": "Stability AI Upscale Creative",
- "StabilityUpscaleFastNode": "Stability AI Upscale Fast",
-}
+ return comfy_io.NodeOutput(returned_image)
+
+
+class StabilityExtension(ComfyExtension):
+ @override
+ async def get_node_list(self) -> list[type[comfy_io.ComfyNode]]:
+ return [
+ StabilityStableImageUltraNode,
+ StabilityStableImageSD_3_5Node,
+ StabilityUpscaleConservativeNode,
+ StabilityUpscaleCreativeNode,
+ StabilityUpscaleFastNode,
+ ]
+
+
+async def comfy_entrypoint() -> StabilityExtension:
+ return StabilityExtension()