Photo to Cartoon Style Caricature
This workflow is as simple as uploading your picture and selecting one of 15 preset cartoon styles to transform it into.
简介
This ComfyUI workflow turns a regular photo into a cartoon-style caricature using one of 15 preset looks. It starts with LoadImage for your source photo, passes your style choice from a CustomCombo dropdown, extracts the matching preset parameters via JsonExtractString, and assembles any required identifiers with StringConcatenate. The core stylization happens in a custom processing node (UUID d4c06663-cb1a-4a41-a36b-f09c93e55e7e), which takes the source image plus the selected style key and outputs a single stylized frame.
You can inspect results live with PreviewAny and save the final image via SaveImage.
Under the hood, the preset system keeps results consistent and repeatable across images. The JSON-driven mapping decouples the user-friendly style names from the actual configuration values the processing node expects, making it easy to swap styles without touching low-level settings. Because the heavy lifting is encapsulated inside the d4c06663-cb1a-4a41-a36b-f09c93e55e7e node, the graph stays simple and fast to use—no additional model loading or sampler tuning required.
你需要提供
- 正在读取工作流
在 ComfyUI 中运行。 此工作流无法在本页面运行。你可以在 Comfy Cloud 中打开(已预先加载所需内容),或下载后在自己的 ComfyUI 中使用。
在 Cloud 中试用查看工作流内部
节点图的只读预览。在 Comfy Cloud 中打开或下载后即可编辑节点。
Loading the graph
Open full-size workflow preview- 作者
- Rob
需要自定义节点
- 正在读取工作流
通过代码使用此工作流
尽可能根据工作流图和输入自动生成代码,否则显示已保存的示例。运行代码可能产生费用,请先核对凭据和端点。
What you need
- Runs on
- Comfy Cloud
- 密钥
- COMFY_API_KEY
需要付费的 Cloud 方案和额度。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"132": {
"class_type": "LoadImage",
"inputs": {
"image": "f91bccebcc07a40d5c61625f96084268613a1845ca64f9472c54e37d7a1733db.png"
},
"_meta": {
"title": "Load Image"
}
},
"197": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Qwen_Edit_2511",
"images": [
"196:175",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"234": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": " ",
"string_a": "Keep the exact same composition, camera framing, crop, pose, character outfit, background, environment, perspective, and lighting as the original photo.",
"string_b": [
"240",
0
]
},
"_meta": {
"title": "Assemble Prompt"
}
},
"235": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"234",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"239": {
"class_type": "CustomCombo",
"inputs": {
"choice": "Classic Caricature"
},
"_meta": {
"title": "Cartoon Style"
}
},
"240": {
"class_type": "JsonExtractString",
"inputs": {
"json_string": "{\n \"Classic Caricature\": \"Transform the attached photo into a caricature portrait in the tradition of classic literary and editorial caricature illustration \\u2014 enlarge the head slightly and perch it on a smaller, elongated body. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Sunday Comics\": \"Transform the attached photo into a vintage Sunday newspaper comic-strip caricature: bold confident ink outlines, flat saturated colors over visible Ben-Day halftone dots, slight newsprint texture and off-register color charm, cheerful panel-ready energy, slightly oversized head on a compact body. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Watercolor Sketch\": \"Transform the attached photo into a loose watercolor caricature sketch: soft pencil underdrawing with expressive, flowing watercolor washes, gentle color bleeds, and airy unpainted paper showing through. Slightly enlarged head with delicate, painterly features. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Street Fair Caricature\": \"Transform the attached photo into a lively caricature done in bold marker and quick airbrush: a big expressive grin, huge head on a tiny dynamic body, spontaneous drawn-while-you-wait energy. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Rubber-Hose\": \"Transform the attached photo into a rubber-hose cartoon: rubberhose animation style, exaggerated stringy limb length, white gloves, thick bouncy outlines, soft film grain and gleeful old-timey charm. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Anime Chibi\": \"Transform the attached photo into a chibi anime caricature: super-deformed proportions with an oversized head and tiny body, huge expressive sparkling eyes, simplified button nose, clean cel-shaded line art. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Vinyl Collectible\": \"Transform the attached photo into a glossy 3D collectible vinyl-toy caricature figure: smooth sculpted surfaces, oversized head on a small stylized body, soft studio lighting with clean reflections, premium designer-toy finish. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Oil Painting Satire\": \"Transform the attached photo into an 18th-century oil painting caricature: rich visible brushwork, warm old-master palette, theatrical chiaroscuro lighting, varnished gallery finish, subtly exaggerated proportions in the grand satirical portrait tradition. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Inflatable Balloon\": \"Transform the attached photo into a shiny inflatable balloon caricature: taut glossy balloon-vinyl skin, softly over-inflated puffy cheeks and limbs, visible welded seams and a small inflation valve, squeaky rubber highlights, buoyant parade-float presence. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Claymation\": \"Transform the attached photo into a hand-sculpted claymation caricature: matte plasticine surface with visible thumbprints and sculpting-tool marks, slightly lumpy hand-modeled shapes, big expressive sculpted brow and smile, stop-motion charm. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Paper Cutout\": \"Transform the attached photo into a layered paper-cutout collage caricature: flat construction-paper shapes with torn and scissor-cut edges, visible drop shadows between paper layers, slightly wobbly hand-cut lines, bold flat colors. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Pixel Sprite\": \"Transform the attached photo into a retro 16-bit pixel-art sprite caricature: chunky visible pixels, limited vibrant color palette, crisp dithered shading, oversized head sprite proportions. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Bobblehead\": \"Transform the attached photo into a plastic exaggerated extremely large bobblehead figurine caricature: oversized wobbling head on a small neck and rigid body, hand-painted finish with subtle brush marks, collectible desk-toy presence. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\",\n \"Neon Airbrush\": \"Transform the attached photo into a 90s neon airbrush caricature: vivid fluorescent airbrushed gradients over deep black shading, glowing neon rim light, confident freehand spray strokes, retro boardwalk T-shirt art energy. Preserve the subject's true likeness and identity while wittily exaggerating their most distinctive features.\"\n}",
"key": [
"239",
0
]
},
"_meta": {
"title": "Style Prompt (JSON)"
}
},
"196:152": {
"class_type": "CFGNorm",
"inputs": {
"model": [
"196:155",
0
],
"pre_cfg": False,
"strength": 1
},
"_meta": {
"title": "CFGNorm"
}
},
"196:155": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"196:166",
0
],
"sampling": "flow",
"shift": 3.1
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"196:156": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"196:161": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"196:167",
0
],
"image1": [
"196:176",
0
],
"prompt": [
"235",
0
],
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "TextEncodeQwenImageEditPlus (Positive)"
}
},
"196:162": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors",
"model": [
"196:152",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"196:163": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 4
},
"_meta": {
"title": "CFG"
}
},
"196:164": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 1
},
"_meta": {
"title": "CFG"
}
},
"196:165": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"196:176",
0
],
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"196:166": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2511_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"196:167": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"196:168": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"196:152",
0
],
"on_true": [
"196:162",
0
],
"switch": [
"196:171",
0
]
},
"_meta": {
"title": "Switch (Model)"
}
},
"196:169": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 6
},
"_meta": {
"title": "Steps"
}
},
"196:170": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 30
},
"_meta": {
"title": "Steps"
}
},
"196:171": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": True
},
"_meta": {
"title": "Enable 4steps LoRA?"
}
},
"196:172": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"196:163",
0
],
"on_true": [
"196:164",
0
],
"switch": [
"196:171",
0
]
},
"_meta": {
"title": "Switch (CFG)"
}
},
"196:173": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"196:170",
0
],
"on_true": [
"196:169",
0
],
"switch": [
"196:171",
0
]
},
"_meta": {
"title": "Switch (Steps)"
}
},
"196:174": {
"class_type": "KSampler",
"inputs": {
"cfg": [
"196:172",
0
],
"denoise": 1,
"latent_image": [
"196:165",
0
],
"model": [
"196:168",
0
],
"negative": [
"196:229",
0
],
"positive": [
"196:161",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 1029537144521435,
"steps": [
"196:173",
0
]
},
"_meta": {
"title": "KSampler"
}
},
"196:175": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"196:174",
0
],
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"196:176": {
"class_type": "FluxKontextImageScale",
"inputs": {
"image": [
"132",
0
]
},
"_meta": {
"title": "FluxKontextImageScale"
}
},
"196:229": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"196:167",
0
],
"image1": [
"196:176",
0
],
"prompt": "",
"vae": [
"196:156",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)常见问答
You can extend the presets only if the processing node (d4c06663-cb1a-4a41-a36b-f09c93e55e7e) recognizes additional style keys. Update the JSON presets feeding JsonExtractString and add the new option to CustomCombo. If the node doesn’t support the new key, it will fall back or fail.
It depends on how the custom processing node is implemented on your system. Many stylization nodes prefer a GPU and will run much faster with one, but some builds can run on CPU at reduced speed.
Portraits at 512–1024 px on the shortest side typically produce clean lines and colors. Crop to the head and shoulders when possible, use even lighting, and avoid heavy motion blur.
This graph focuses on single-image input via LoadImage. For batches, duplicate the branch or swap in a batch-capable loader node and feed the same CustomCombo/JSON preset mapping into the processor.