Root cause of nodes not appearing in ComfyUI: this package's node classes originally reused the exact same class names as the internal fal-flux-nodes package it was migrated from (e.g. NanoBananaProEditNode, SeedreamV45EditNode). ComfyUI's NODE_CLASS_MAPPINGS is a flat global dict - when both packages are installed, whichever loads first wins and the other's registration for that key is silently dropped, which is why none of the "Superside "-prefixed nodes were showing up. Every class is now uniquely prefixed (e.g. SupersideNanoBananaProEditNode), so this package can never collide with fal-flux-nodes, ComfyUI-fal-API, or any other node pack regardless of install order. Updated __init__.py, web/js/show_text.js's TEXT_DISPLAY_NODES list, and README.md to match.
111 lines
3.6 KiB
Python
111 lines
3.6 KiB
Python
import logging
|
|
|
|
from .base_node import (
|
|
APIClientMixin,
|
|
SupersideFalNode,
|
|
ImageProcessingMixin,
|
|
API_KEY_INPUT_SPEC,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class SupersideSeedVR2UpscaleImageNode(
|
|
SupersideFalNode, ImageProcessingMixin, APIClientMixin
|
|
):
|
|
"""
|
|
SeedVR v2 Upscale Image Node: Upscale images using SeedVR's seamless
|
|
image upscaler via fal.ai API.
|
|
"""
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"image": ("IMAGE",),
|
|
"api_key": API_KEY_INPUT_SPEC,
|
|
},
|
|
"optional": {
|
|
"upscale_mode": (["target", "factor"], {"default": "factor"}),
|
|
"upscale_factor": (
|
|
"FLOAT",
|
|
{
|
|
"default": 2.0,
|
|
"min": 1.0,
|
|
"max": 10.0,
|
|
"step": 0.1,
|
|
"display": "slider",
|
|
},
|
|
),
|
|
"target_resolution": (
|
|
["720p", "1080p", "1440p", "2160p"],
|
|
{"default": "1080p"},
|
|
),
|
|
"seed": ("INT", {"min": 0, "max": 0xFFFFFFFFFFFFFFFF}),
|
|
"noise_scale": (
|
|
"FLOAT",
|
|
{
|
|
"default": 0.1,
|
|
"min": 0.0,
|
|
"max": 1.0,
|
|
"step": 0.001,
|
|
"display": "slider",
|
|
},
|
|
),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("IMAGE",)
|
|
FUNCTION = "upscale"
|
|
DISPLAY_NAME = "SeedVR2 Upscale Image"
|
|
DESCRIPTION = "Upscale images using SeedVR2 seamless image upscaling"
|
|
|
|
def prepare_arguments(self, client, image, **kwargs):
|
|
"""Prepare arguments for the API call."""
|
|
arguments = {
|
|
"image_url": self.upload_image(client, image),
|
|
}
|
|
|
|
if kwargs.get("upscale_mode") is not None:
|
|
arguments["upscale_mode"] = kwargs["upscale_mode"]
|
|
|
|
if kwargs.get("target_resolution") is not None:
|
|
arguments["target_resolution"] = kwargs["target_resolution"]
|
|
|
|
if kwargs.get("upscale_factor") is not None:
|
|
arguments["upscale_factor"] = kwargs["upscale_factor"]
|
|
|
|
if kwargs.get("noise_scale") is not None:
|
|
arguments["noise_scale"] = kwargs["noise_scale"]
|
|
|
|
if kwargs.get("seed") not in (None, 0):
|
|
arguments["seed"] = kwargs["seed"]
|
|
|
|
return arguments
|
|
|
|
def process_seedvr_result(self, result):
|
|
"""Process SeedVR's single-image response format."""
|
|
if "image" not in result or not result["image"]:
|
|
raise RuntimeError("No image was generated by the API.")
|
|
|
|
img_info = result["image"]
|
|
logger.debug(f"Processing SeedVR 2 image: {img_info}")
|
|
|
|
if not isinstance(img_info, dict) or "url" not in img_info:
|
|
raise RuntimeError("Invalid image format in response")
|
|
|
|
return self.process_images({"images": [img_info]})
|
|
|
|
def upscale(self, image, api_key, **kwargs):
|
|
"""Main upscaling function."""
|
|
try:
|
|
client = self.get_client(api_key)
|
|
arguments = self.prepare_arguments(client, image, **kwargs)
|
|
logger.info(f"Calling SeedVR 2 API with arguments: {arguments}")
|
|
|
|
result = self.call_api(client, "fal-ai/seedvr/upscale/image/seamless", arguments)
|
|
return self.process_seedvr_result(result)
|
|
except Exception as e:
|
|
logger.error(f"SeedVR 2 upscaling failed: {str(e)}")
|
|
raise
|