Nodes/ComfyUI-Pt-Wrapper/Ptn Conv Model
ComfyUI Node

Ptn Conv Model

A whole CNN from a few text fields, no coding

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptn Conv Model
    • PTMODEL
    input_dim(3,28,28)
    penultimate_dim0
    output_dim10
    channel_list[32,64,128,256,512]
    kernel_size_list[3,3,3,3,1]
    padding_list[1,1,1,1,0]
    downsample_list[True,True,True,True,False]

    Ptn Conv Model is the pack's pre-built convolutional neural network - the node you grab when you want a real image classifier without assembling conv layers by hand. You describe the architecture in a few text fields - input shape, channel list, kernel sizes, where to downsample - and it hands back a complete PTMODEL: a stack of Conv2d layers with ReLU activations, optional 2×2 max-pooling between them, and a final linear classification head. It's the node behind the Fashion-MNIST and CIFAR-10 example workflows in the pack docs.

    Why you'd reach for it

    If your goal is "train a classifier on images and learn how it behaves," this is the fastest honest path in the pack. The defaults are a sensible five-layer net - channels [32, 64, 128, 256, 512], kernel 3, padding 1, downsampling after each layer except the last - which is more than enough for CIFAR-10-class tasks (the author reports ~94% validation accuracy on CIFAR-10 with their training workflows). You tweak the text fields rather than rebuild the graph, which makes it the ideal place to start experimenting: change channel_list, see what happens to accuracy. And because it's just a PTMODEL, you can still chain extra layers onto it afterward.

    How it works

    Under the hood it's a ConvModel module: the input's channel count comes from the first element of input_dim (e.g. (3, 28, 28)), each entry in channel_list becomes a conv layer, and each True in downsample_list inserts a 2×2 max pool. Every conv gets a ReLU and kaiming init. The conv stack ends flattened into a dense layer; penultimate_dim is the size of that hidden layer (set 0 and the pack computes a reasonable number for you), and output_dim is the number of classes. All the lists are parsed from text with ast.literal_eval, so the brackets and commas have to be valid Python.

    The inputs

    • input_dim (default "(3,28,28)") - one sample's shape as (C, H, W).
    • channel_list - per-layer channel counts, excluding the input channel.
    • kernel_size_list / padding_list - per-layer kernel sizes and paddings.
    • downsample_list - per-layer booleans for whether to max-pool.
    • penultimate_dim (default 0) - features before the head; 0 = auto-computed.
    • output_dim (default 10) - number of classes.

    Output: PTMODEL.

    Installing the pack

    In the "Training" category. Install via ComfyUI Manager (search "ComfyUI-Pt-Wrapper") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
    

    Restart ComfyUI. Install pulls in transformers, datasets, peft, scikit-learn, gensim and more; example-workflow datasets download on demand when you run them.

    Common issues

    • List length mismatch - channel_list, kernel_size_list, padding_list, and downsample_list must all be the same length, or the model raises a validation error at build time.
    • Input dim vs dataset - input_dim must match your actual data. Point it at 28×28 grayscale data with (3,28,28) and the first forward pass blows up; for single-channel grayscale the channel count should be 1.
    • List syntax - every list field must be valid Python literal syntax: "[32, 64]" with brackets. A missing bracket is an immediate parse error.
    • Big lists, slow runs - the model rebuilds every graph run, and big conv stacks are real work. If your runs crawl, trim channel_list.
    • Thin support - single-author educational pack, essentially absent from r/comfyui discussion. The model-training docs on the repo (Fashion-MNIST and CIFAR-10 walkthroughs) are your best teachers.
    CategoryTraining

    Inputs (7)

    NameTypeDefaultDescription
    input_dimSTRING(3,28,28)
    penultimate_dimINT00–1000000
    output_dimINT101–1000000
    channel_listSTRING[32,64,128,256,512]
    kernel_size_listSTRING[3,3,3,3,1]
    padding_listSTRING[1,1,1,1,0]
    downsample_listSTRING[True,True,True,True,False]

    Outputs (1)

    NameTypeDescription
    PTMODELPTMODEL