Apply arbitrary ONNX image-processing models to images inside ComfyUI.
Models under ComfyUI/models/onnx/ (including nested folders) appear in a dropdown — no manual path editing.
- Recursive discovery of
.onnxfiles undermodels/onnx/ - Automatic ONNX graph inspection (input/output names, shapes, dtypes, NCHW/NHWC)
- RGB / RGBA / grayscale handling with automatic conversion and alpha restore
uint8/float16/float32IO with normalize-only-when-needed- Dynamic spatial / batch shapes
- Image sequences / batches (
B,H,W,C) processed frame-wise or in chunks - Optional tiling with overlap blending
- CUDA-first provider selection with automatic CPU fallback
- Cached
InferenceSessionreuse - Favorites, live metadata preview, and optional benchmark node
- Copy or clone this repository into ComfyUI's custom nodes folder:
ComfyUI/custom_nodes/ComfyUI-ONNX/
- Install Python dependencies into the same environment ComfyUI uses:
cd ComfyUI/custom_nodes/ComfyUI-ONNX
pip install -r requirements.txt- (Optional, GPU) Install the CUDA build of ONNX Runtime instead of / in addition to the CPU wheel:
pip uninstall -y onnxruntime
pip install onnxruntime-gpu>=1.18- Create the models folder (created automatically on first load) and add models:
ComfyUI/models/onnx/
├── Anime/anime_v1.onnx
├── Upscale/realesrgan.onnx
└── Stylization/monet.onnx
- Restart ComfyUI.
| Package | Required | Notes |
|---|---|---|
onnxruntime |
Yes (CPU) | >= 1.18 |
onnxruntime-gpu |
Optional | CUDA 12.x builds recommended |
onnx |
Yes | Graph / opset / parameter inspection |
numpy |
Yes | |
torch |
Yes | Already provided by ComfyUI |
Pillow |
Yes | Already provided by ComfyUI |
Supported platforms: Windows, Linux, Python 3.10+, ComfyUI latest.
| Input | Description |
|---|---|
| IMAGE | Input image |
| MODEL | Dropdown of discovered ONNX models |
| DEVICE | Auto / CUDA / CPU |
| Provider | Auto / CUDAExecutionProvider / CPUExecutionProvider |
| Refresh Models | Rescan models/onnx/ (then refresh node definitions / page to update the dropdown) |
| Tile Size | 0 = disabled; otherwise split into tiles |
| Overlap | Tile overlap (default 32) |
| FP16 | Prefer half precision when supported |
| Batch Size | Frames per ONNX run for sequences (default 1 = one frame at a time) |
| Favorite | Mark the current model as a favorite |
| Run Benchmark | Append benchmark stats to metadata |
| Output | Description |
|---|---|
| IMAGE | Processed image |
| metadata | Model summary (shapes, provider, opset, timings, …) |
Add / remove favorites. Favorites appear at the top of the dropdown with a ★ prefix.
Runs a synthetic benchmark and reports average time, FPS, provider, and CPU vs GPU speed when possible.
Load Image
│
▼
ONNX Image Filter
│
▼
Save Image
- Add Load Image
- Add ONNX Image Filter (
Image/ONNX) - Select a model from the dropdown
- Connect to Save Image / Preview Image
Connect the metadata output to a Show Text / Preview Any node if you want the inspection summary visible on the canvas.
Place screenshots in
docs/if you publish this package:
docs/node.png— the ONNX Image Filter nodedocs/workflow.png— Load Image → ONNX Image Filter → Save Imagedocs/models_folder.png— examplemodels/onnx/layout
Preferred order when Device and Provider are Auto:
CUDAExecutionProviderCPUExecutionProvider
After session creation the node verifies that CUDA actually activated. ORT can silently ignore a broken CUDA install; when that happens the node logs a warning and continues on CPU.
If CUDA is unavailable, the node falls back to CPU and continues. It will not crash solely because GPU ORT is missing.
CUDA sessions use ComfyUI/PyTorch's current GPU index (device_id) and standard
ORT options (arena_extend_strategy, cudnn_conv_use_max_workspace,
do_copy_in_default_stream).
- Install a CUDA 12.x-compatible GPU driver.
- Install
onnxruntime-gpu>=1.18into the ComfyUI Python environment (do not keep the CPU-onlyonnxruntimewheel alongside it). - Confirm providers in a Python shell:
import onnxruntime as ort
print(ort.get_available_providers())You should see CUDAExecutionProvider listed when the GPU build is working.
- Set Device to
CPU, or Provider toCPUExecutionProvider - Or simply leave Auto and let the node fall back when CUDA is missing
The FP16 checkbox uses float16 feeds only when the ONNX model input is already
float16. It does not convert float32 models. For half-precision IO, export or
download a float16 ONNX graph.
The node does not assume fixed input names, layouts, or dtypes. On load it inspects the ONNX graph / ORT session and detects:
- Input / output tensor names
- Datatypes (
uint8,float16,float32, …) - Shape + dynamic axes
- Channel count and layout (
NCHW/NHWC) - Whether values are likely
0–255vs0–1
ComfyUI images (B,H,W,C float [0,1]) are converted automatically and converted back after inference.
Set Tile Size > 0 to process large images in overlapping tiles. Overlaps are feather-blended to reduce seams. Useful for high-resolution inputs or memory-constrained GPUs.
Each run prints a console summary similar to:
[ComfyUI-ONNX] Loaded model: .../models/onnx/Anime/anime_v1.onnx
[ComfyUI-ONNX] Provider: CUDAExecutionProvider (device 0)
[ComfyUI-ONNX] Active providers: ['CUDAExecutionProvider', 'CPUExecutionProvider']
[ComfyUI-ONNX] Input: input (1, 3, 512, 512) (1 frame(s))
[ComfyUI-ONNX] Output: output (1, 3, ?, ?)
[ComfyUI-ONNX] Datatype: float32 -> float32
[ComfyUI-ONNX] Resolution: 1x3x512x512
[ComfyUI-ONNX] Inference time: 0.0421s
Enable full Python tracebacks with:
set COMFYUI_ONNX_DEBUG=1| Symptom | Fix |
|---|---|
(no onnx models found) |
Put .onnx files under ComfyUI/models/onnx/, toggle Refresh Models, then refresh the browser / node definitions |
CUDA provider unavailable |
Install onnxruntime-gpu, or switch Device/Provider to CPU |
Model has multiple inputs |
Only single-image-input models are supported |
Unsupported tensor shape |
Model input/output is not rank 3/4 image-like |
Input channels mismatch |
Model expects a channel count that cannot be derived from RGB/RGBA/GRAY |
Invalid ONNX graph |
Re-export / validate the model with the onnx package |
| Dropdown not updating | Refresh Models clears the scan cache; reload the UI so INPUT_TYPES is re-evaluated |
| Slow CPU runs | Expected without onnxruntime-gpu; try tiling to reduce peak memory on GPU |
Q: Where do I put models?
ComfyUI/models/onnx/ — nested folders are fine. Dropdown labels use relative paths such as Upscale/realesrgan.onnx.
Q: Do I need to edit paths in the node?
No. Discovery is automatic.
Q: Can I search hundreds of models?
Use ComfyUI's built-in combo filter (type to filter). Favorites float matching models to the top.
Q: Are sessions reloaded every run?
No. Sessions are cached by model path + provider + FP16 preference and reused until ComfyUI exits.
Q: Does FP16 always help?
Only when the ONNX model itself uses float16 IO. Float32 models stay float32;
enable CUDA via onnxruntime-gpu for GPU float32 acceleration.
Q: Multi-input / multi-output models?
Multiple image inputs are rejected with a clear error. Multiple outputs: the first image-like output is used.
- Automatic metadata display (
metadataoutput + console logs) - Live preview panel when the model changes (web extension)
- Favorites (
★prefix + Favorite toggle / helper node) - Combo search via ComfyUI's native filterable dropdowns
- Benchmark button / dedicated benchmark node (avg time, FPS, CPU vs GPU)
MIT — see LICENSE.