Expose 4 remaining Recraft nodes (#112)

This commit is contained in:
Jedrzej Kosinski 2025-05-02 14:10:46 -05:00 committed by GitHub
parent e7f241071b
commit 1178022a7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 10 deletions

View File

@ -247,6 +247,7 @@ class RecraftImageGenerationRequest(BaseModel):
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') style_id: Optional[str] = Field(None, description='Use a previously uploaded style as a reference; UUID')
strength: Optional[confloat(ge=0.0, le=1.0)] = Field(None, description='Defines the difference with the original image, should lie in [0, 1], where 0 means almost identical, and 1 means miserable similarity') strength: Optional[confloat(ge=0.0, le=1.0)] = Field(None, description='Defines the difference with the original image, should lie in [0, 1], where 0 means almost identical, and 1 means miserable similarity')
random_seed: Optional[int] = Field(None, description="Seed for video generation")
# text_layout # text_layout

View File

@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
from inspect import cleandoc from inspect import cleandoc
from comfy.utils import ProgressBar from comfy.utils import ProgressBar, common_upscale
from comfy.comfy_types.node_typing import IO from comfy.comfy_types.node_typing import IO
from comfy_api_nodes.apis.recraft_api import ( from comfy_api_nodes.apis.recraft_api import (
RecraftImageGenerationRequest, RecraftImageGenerationRequest,
@ -542,6 +542,7 @@ class RecraftImageToImageNode:
substyle=recraft_style.substyle, substyle=recraft_style.substyle,
style_id=recraft_style.style_id, style_id=recraft_style.style_id,
controls=controls_api, controls=controls_api,
random_seed=seed,
) )
images = [] images = []
@ -649,8 +650,17 @@ class RecraftImageInpaintingNode:
style=recraft_style.style, style=recraft_style.style,
substyle=recraft_style.substyle, substyle=recraft_style.substyle,
style_id=recraft_style.style_id, style_id=recraft_style.style_id,
random_seed=seed,
) )
# prepare mask tensor
_, H, W, _ = image.shape
mask = mask.unsqueeze(-1)
mask = mask.movedim(-1,1)
mask = common_upscale(mask, width=W, height=H, upscale_method="nearest-exact", crop="disabled")
mask = mask.movedim(1,-1)
mask = (mask > 0.5).float()
images = [] images = []
total = image.shape[0] total = image.shape[0]
pbar = ProgressBar(total) pbar = ProgressBar(total)
@ -658,7 +668,7 @@ class RecraftImageInpaintingNode:
sub_bytes = handle_recraft_file_request( sub_bytes = handle_recraft_file_request(
image=image[i], image=image[i],
mask=mask[i:i+1], mask=mask[i:i+1],
path="/proxy/recraft/images/imageInpainting", path="/proxy/recraft/images/inpaint",
request=request, request=request,
auth_token=auth_token, auth_token=auth_token,
) )
@ -1056,14 +1066,14 @@ class RecraftCreativeUpscaleNode(RecraftCrispUpscaleNode):
# NOTE: names should be globally unique # NOTE: names should be globally unique
NODE_CLASS_MAPPINGS = { NODE_CLASS_MAPPINGS = {
"RecraftTextToImageNode": RecraftTextToImageNode, "RecraftTextToImageNode": RecraftTextToImageNode,
# "RecraftImageToImageNode": RecraftImageToImageNode, "RecraftImageToImageNode": RecraftImageToImageNode,
# "RecraftImageInpaintingNode": RecraftImageInpaintingNode, "RecraftImageInpaintingNode": RecraftImageInpaintingNode,
"RecraftTextToVectorNode": RecraftTextToVectorNode, "RecraftTextToVectorNode": RecraftTextToVectorNode,
"RecraftVectorizeImageNode": RecraftVectorizeImageNode, "RecraftVectorizeImageNode": RecraftVectorizeImageNode,
"RecraftRemoveBackgroundNode": RecraftRemoveBackgroundNode, "RecraftRemoveBackgroundNode": RecraftRemoveBackgroundNode,
# "RecraftReplaceBackgroundNode": RecraftReplaceBackgroundNode, "RecraftReplaceBackgroundNode": RecraftReplaceBackgroundNode,
"RecraftCrispUpscaleNode": RecraftCrispUpscaleNode, "RecraftCrispUpscaleNode": RecraftCrispUpscaleNode,
# "RecraftCreativeUpscaleNode": RecraftCreativeUpscaleNode, "RecraftCreativeUpscaleNode": RecraftCreativeUpscaleNode,
"RecraftStyleV3RealisticImage": RecraftStyleV3RealisticImageNode, "RecraftStyleV3RealisticImage": RecraftStyleV3RealisticImageNode,
"RecraftStyleV3DigitalIllustration": RecraftStyleV3DigitalIllustrationNode, "RecraftStyleV3DigitalIllustration": RecraftStyleV3DigitalIllustrationNode,
"RecraftStyleV3LogoRaster": RecraftStyleV3LogoRasterNode, "RecraftStyleV3LogoRaster": RecraftStyleV3LogoRasterNode,
@ -1075,14 +1085,14 @@ NODE_CLASS_MAPPINGS = {
# A dictionary that contains the friendly/humanly readable titles for the nodes # A dictionary that contains the friendly/humanly readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = { NODE_DISPLAY_NAME_MAPPINGS = {
"RecraftTextToImageNode": "Recraft Text to Image", "RecraftTextToImageNode": "Recraft Text to Image",
# "RecraftImageToImageNode": "Recraft Image to Image", "RecraftImageToImageNode": "Recraft Image to Image",
# "RecraftImageInpaintingNode": "Recraft Image Inpainting", "RecraftImageInpaintingNode": "Recraft Image Inpainting",
"RecraftTextToVectorNode": "Recraft Text to Vector", "RecraftTextToVectorNode": "Recraft Text to Vector",
"RecraftVectorizeImageNode": "Recraft Vectorize Image", "RecraftVectorizeImageNode": "Recraft Vectorize Image",
"RecraftRemoveBackgroundNode": "Recraft Remove Background", "RecraftRemoveBackgroundNode": "Recraft Remove Background",
# "RecraftReplaceBackgroundNode": "Recraft Replace Background", "RecraftReplaceBackgroundNode": "Recraft Replace Background",
"RecraftCrispUpscaleNode": "Recraft Crisp Upscale Image", "RecraftCrispUpscaleNode": "Recraft Crisp Upscale Image",
# "RecraftCreativeUpscaleNode": "Recraft Creative Upscale Image", "RecraftCreativeUpscaleNode": "Recraft Creative Upscale Image",
"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",