Added Recraft Style - Infinite Style Library node (#82)

This commit is contained in:
Jedrzej Kosinski 2025-04-30 18:00:09 -05:00
parent 3cf4671111
commit 6b841b31f3
2 changed files with 39 additions and 2 deletions

View File

@ -71,11 +71,12 @@ class RecraftControls:
class RecraftStyle: class RecraftStyle:
def __init__(self, style: str, substyle: str=None): def __init__(self, style: str=None, substyle: str=None, style_id: str=None):
self.style = style self.style = style
if substyle == "None": if substyle == "None":
substyle = None substyle = None
self.substyle = substyle self.substyle = substyle
self.style_id = style_id
class RecraftIO: class RecraftIO:
@ -244,6 +245,7 @@ class RecraftImageGenerationRequest(BaseModel):
style: Optional[str] = Field(None, description='The style to apply to the generated image (e.g., "digital_illustration")') style: Optional[str] = Field(None, description='The style to apply to the generated image (e.g., "digital_illustration")')
substyle: Optional[str] = Field(None, description='The substyle to apply to the generated image, depending on the style input') substyle: Optional[str] = Field(None, description='The substyle to apply to the generated image, depending on the style input')
controls: Optional[RecraftControlsObject] = Field(None, description='A set of custom parameters to tweak generation process') controls: Optional[RecraftControlsObject] = Field(None, description='A set of custom parameters to tweak generation process')
style_id: Optional[str] = Field(None, description='Use a previously uploaded style as a reference; UUID')
# text_layout # text_layout

View File

@ -48,6 +48,7 @@ class SaveSVGNode:
self.prefix_append = "" self.prefix_append = ""
RETURN_TYPES = () RETURN_TYPES = ()
DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
FUNCTION = "save_svg" FUNCTION = "save_svg"
CATEGORY = "api node/image/Recraft" CATEGORY = "api node/image/Recraft"
OUTPUT_NODE = True OUTPUT_NODE = True
@ -100,6 +101,7 @@ class RecraftColorRGBNode:
""" """
RETURN_TYPES = (RecraftIO.COLOR,) RETURN_TYPES = (RecraftIO.COLOR,)
DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
RETURN_NAMES = ("recraft_color",) RETURN_NAMES = ("recraft_color",)
FUNCTION = "create_color" FUNCTION = "create_color"
CATEGORY = "api node/image/Recraft" CATEGORY = "api node/image/Recraft"
@ -145,6 +147,7 @@ class RecraftControlsNode:
RETURN_TYPES = (RecraftIO.CONTROLS,) RETURN_TYPES = (RecraftIO.CONTROLS,)
RETURN_NAMES = ("recraft_controls",) RETURN_NAMES = ("recraft_controls",)
DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
FUNCTION = "create_controls" FUNCTION = "create_controls"
CATEGORY = "api node/image/Recraft" CATEGORY = "api node/image/Recraft"
@ -170,6 +173,7 @@ class RecraftStyleV3RealisticImageNode:
RETURN_TYPES = (RecraftIO.STYLEV3,) RETURN_TYPES = (RecraftIO.STYLEV3,)
RETURN_NAMES = ("recraft_style",) RETURN_NAMES = ("recraft_style",)
DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
FUNCTION = "create_style" FUNCTION = "create_style"
CATEGORY = "api node/image/Recraft" CATEGORY = "api node/image/Recraft"
@ -221,6 +225,34 @@ class RecraftStyleV3LogoRasterNode(RecraftStyleV3RealisticImageNode):
RECRAFT_STYLE = RecraftStyleV3.logo_raster RECRAFT_STYLE = RecraftStyleV3.logo_raster
class RecraftStyleInfiniteStyleLibrary:
"""
Select style based on preexisting UUID from the Infinite Style Library.
"""
RETURN_TYPES = (RecraftIO.STYLEV3,)
RETURN_NAMES = ("recraft_style",)
DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
FUNCTION = "create_style"
CATEGORY = "api node/image/Recraft"
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"style_id": (IO.STRING, {
"default": "",
"tooltip": "UUID of style from Infinite Style Library.",
})
}
}
def create_style(self, style_id: str):
if not style_id:
raise Exception("The style_id input cannot be empty.")
return (RecraftStyle(style_id=style_id),)
class RecraftTextToImageNode: class RecraftTextToImageNode:
""" """
Generates images synchronously based on prompt and resolution. Generates images synchronously based on prompt and resolution.
@ -305,7 +337,7 @@ class RecraftTextToImageNode:
auth_token=None, auth_token=None,
**kwargs, **kwargs,
): ):
default_style = RecraftStyle(RecraftStyleV3.digital_illustration) default_style = RecraftStyle(RecraftStyleV3.realistic_image)
if recraft_style is None: if recraft_style is None:
recraft_style = default_style recraft_style = default_style
@ -331,6 +363,7 @@ class RecraftTextToImageNode:
n=n, n=n,
style=recraft_style.style, style=recraft_style.style,
substyle=recraft_style.substyle, substyle=recraft_style.substyle,
style_id=recraft_style.style_id,
controls=controls_api, controls=controls_api,
), ),
auth_token=auth_token, auth_token=auth_token,
@ -478,6 +511,7 @@ NODE_CLASS_MAPPINGS = {
"RecraftStyleV3RealisticImage": RecraftStyleV3RealisticImageNode, "RecraftStyleV3RealisticImage": RecraftStyleV3RealisticImageNode,
"RecraftStyleV3DigitalIllustration": RecraftStyleV3DigitalIllustrationNode, "RecraftStyleV3DigitalIllustration": RecraftStyleV3DigitalIllustrationNode,
"RecraftStyleV3LogoRaster": RecraftStyleV3LogoRasterNode, "RecraftStyleV3LogoRaster": RecraftStyleV3LogoRasterNode,
"RecraftStyleV3InfiniteStyleLibrary": RecraftStyleInfiniteStyleLibrary,
"RecraftColorRGB": RecraftColorRGBNode, "RecraftColorRGB": RecraftColorRGBNode,
"RecraftControls": RecraftControlsNode, "RecraftControls": RecraftControlsNode,
"SaveSVG": SaveSVGNode, "SaveSVG": SaveSVGNode,
@ -490,6 +524,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"RecraftStyleV3RealisticImage": "Recraft Style - Realistic Image", "RecraftStyleV3RealisticImage": "Recraft Style - Realistic Image",
"RecraftStyleV3DigitalIllustration": "Recraft Style - Digital Illustration", "RecraftStyleV3DigitalIllustration": "Recraft Style - Digital Illustration",
"RecraftStyleV3LogoRaster": "Recraft Style - Logo Raster", "RecraftStyleV3LogoRaster": "Recraft Style - Logo Raster",
"RecraftStyleV3InfiniteStyleLibrary": "Recraft Style - Infinite Style Library",
"RecraftColorRGB": "Recraft Color RGB", "RecraftColorRGB": "Recraft Color RGB",
"RecraftControls": "Recraft Controls", "RecraftControls": "Recraft Controls",
"SaveSVG": "Save SVG", "SaveSVG": "Save SVG",