ResNet-18
A real deep network, assembled in one node
- model
The model that won ImageNet and rewrote computer vision, delivered as a single ComfyDL node. CdlResNet18 builds a complete ResNet-18 - the full stack of residual blocks, global average pooling, and a classification head - with two widgets and one output. If you want to train an actual deep network in ComfyUI without hand-assembling 18 layers of blocks, this is the node.
This is the d2l-modified ResNet-18, which means it's the textbook's pedagogical variant rather than the exact torchvision implementation: smaller kernels and strides, no max-pooling layer, and everything designed to run on CPU and tiny image sizes. It's built for learning, and it's the payoff for the hours you spent clicking individual Residual Block nodes - here's the whole thing in one shot.
Architecture, in brief
- Four groups of two residual blocks each, with channel counts 64 → 128 → 256 → 512.
- The first block of each group (except the first) downsamples via stride 2 and a 1×1 shortcut.
- Global average pooling at the end, then a fully connected layer to your class count.
The inputs
num_classes- output classes (default 10, range up to 10000). This is your classifier head width - set it to your dataset's class count.in_channels- input channels (default 1, i.e. grayscale). Set to 3 for RGB input. If you're feeding images from a dataset node, match it to what your images actually have.
Output: model, a cdlModel. Feed it a batch with a forward-pass node, compute loss, take an SGD Step - you've got a full CNN training loop in the graph.
Installing ComfyDL
The pack installs light - matplotlib is the only dependency beyond what ComfyUI ships:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
cd ComfyDL && pip install -r requirements.txt
Restart ComfyUI; it's under ComfyDL → CV Models, or search "ComfyDL" in ComfyUI Manager. No model downloads - the weights are random at construction, which is exactly what you want for training from scratch.
The honest truth about training it
There are no pretrained weights here, and on a desktop GPU-less setup this modified ResNet-18 is designed to train on Fashion-MNIST-scale images in seconds to minutes - not ImageNet. That's the point. If you show up expecting torchvision's pretrained ResNet for feature extraction, you're in the wrong pack; ComfyDL is the teach you how it works pack, and this node is its flagship "look, I trained a deep network" moment.
Practical notes: don't expect in_channels to auto-detect - a 3-channel RGB batch fed to a 1-channel model errors immediately, and the message won't tell you which is wrong. And when you stack this with the pack's SGD Step and loss nodes, keep the learning rate in the 0.01–0.1 range the d2l examples use; too high and you'll watch the loss curve in Plot go the wrong way, which is its own kind of educational experience.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| num_classes | INT | 101–10000 | — |
| in_channels | INT | 11–1024 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | cdlModel | — |