buckmagnetweb's picture
38 production ComfyUI workflows in API format
417843d verified
|
Raw
History Blame Contribute Delete
5.28 kB
---
license: apache-2.0
tags:
- comfyui
- workflows
- image-editing
- qwen-image-edit
- background-removal
- upscaling
pretty_name: Production ComfyUI Workflows (API format)
---
# Production ComfyUI workflows, API format
38 ComfyUI workflows in **API format** (the shape `/prompt` accepts, not the
editor's save format). These are not demos — they are the graphs behind the
image tools on [prathom.ai](https://prathom.ai), running against a single
RTX 4080.
Everything here was debugged against real images. The notes below describe bugs
that were live in production and are easy to reproduce if you build the same
graphs yourself. That is the part worth reading.
## The four bugs, and what they look like
### 1. Background removal produces an inverted alpha
`RemoveBackground` (BiRefNet) returns a mask where **the subject is 0 and the
background is 1**. `JoinImageWithAlpha` wants the opposite. Wire them directly
and you get a transparent PNG of the *background*, with the subject cut out —
the exact inverse of the request. It looks plausible in a thumbnail, which is
why it survives review.
`InvertMask` between them fixes it. See `transparent-png.json`, node 4.
This applies to `JoinImageWithAlpha` only. `ImageCompositeMasked` takes the mask
the other way round, so `product-background.json` and `white-background.json`
correctly have **no** `InvertMask` — adding one "for consistency" breaks them.
The polarity is a property of the consuming node, not of the mask.
### 2. Qwen-Image-Edit silently forces square output
`EmptySD3LatentImage` with literal `width`/`height` sets the output size
regardless of the input. A 1920×1080 photo through a graph with a hardcoded
1024×1024 latent comes back square and stretched.
Two nodes fix it:
```
ImageScaleToTotalPixels(megapixels=1.0, resolution_steps=16)
GetImageSize → EmptySD3LatentImage.width / .height
```
`resolution_steps: 16` matters — latent dimensions must be a multiple of 16 or
the sampler pads and you lose a strip of the image. See any of the 13 edit
workflows, e.g. `anime-converter.json`, nodes 12 and 13.
**Deliberately not applied to the 10 fixed-format workflows.**
`linkedin-banner` (1584×396), `x-header` (1500×500),
`youtube-thumbnail-generator` (1280×720) and the rest must emit their
platform's exact dimensions. Deriving size from the input would break the one
thing those graphs exist to do.
### 3. A hardcoded seed means the retry button does nothing
Every generative workflow started with a literal seed. Someone who disliked
their cartoon and pressed the button again received a byte-for-byte identical
image, with nothing on the page to explain why.
The 20 generative workflows here use `"seed": "{{seed}}"`, and the caller
substitutes a fresh random value per submission.
**Four keep a literal seed on purpose**: `remove-scratches`, `remove-dust`,
`remove-noise`, `ai-face-restore`. Those are restoration passes, where two runs
disagreeing about the same physical damage is a defect rather than a feature.
If you would rather re-roll a restoration, change them — the trade-off is real
and it goes both ways.
### 4. Compositing onto a fixed canvas ignores the source dimensions
`ImageCompositeMasked` with `resize_source: true` and a fixed `EmptyImage`
canvas scales the subject to the canvas rather than placing it on it. Portraits
come back squashed.
`white-background.json` takes the canvas from `GetImageSize` on the input and
sets `resize_source: false`. `ai-passport-photo.json` is the fuller version:
image and mask are scaled separately — `lanczos` for the image, `bilinear` for
the mask, because a sharpening filter on a mask produces ringing at the cut
edge — then recombined through `ImageToMask`.
## Placeholders
These are templates. Substitute before POSTing to `/prompt`:
| Placeholder | Meaning |
|---|---|
| `{{input}}` | filename returned by `/upload/image` |
| `{{seed}}` | fresh random int per submission |
| `{{preset}}` | rescale factor. RealESRGAN emits 4x, so 2x → `0.5`, 4x → `1` |
| `{{instruction}}` | the edit prompt, for the Qwen graphs |
| `{{passportWidth}}`, `{{passportHeight}}` | target size in pixels |
Model filenames are literal and will need changing to match your `models/`
directory.
## Models referenced
```
qwen_image_edit_2509_fp8_e4m3fn.safetensors 23 workflows
qwen_2.5_vl_7b_fp8_scaled.safetensors 23
qwen_image_vae.safetensors 23
birefnet.safetensors 5
RealESRGAN_x4plus.pth 5
ddcolor_paper.pth 2
RealVisXL_V5.0_fp16.safetensors 1
bbox/face_yolov8m.pt 1
```
Tested on ComfyUI 0.30.1 / torch 2.12.1+cu130, RTX 4080 16 GB. The Qwen fp8
graphs fit in 16 GB at 1 MP; they do not at 2 MP.
## One operational note
If you run several of these back to back, check free VRAM **after** unloading
rather than before. Reading it once and refusing on a stale number rejects a
graph for a shortage that a `/free` call would have cleared. It presents as an
out-of-memory error while the GPU sits idle, and it is easy to mistake for a
hardware limit.
## Licence
Apache-2.0, for the workflows. prathom.ai itself is not open source.