Nodes/ComfyUI-Pt-Wrapper/Ptv Transforms Resize
ComfyUI Node

Ptv Transforms Resize

Resize your training images without leaving the graph

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptv Transforms Resize
    • PTVTRANSFORM
    height256
    width256

    Ptv Transforms Resize builds the image preprocessing step for your training pipeline: it produces a transform that resizes every image to a target height and width and converts it to a PyTorch tensor. In the pack's image-classification flows - like the dog-vs-cat tutorial - this is the node that makes your raw images the right size for the model before they ever reach the dataloader.

    It's part of ComfyUI-Pt-Wrapper, the ~200-node pack that brings PyTorch data loading and model training into ComfyUI's graph. The Ptv prefix is the dataset side of the family: these nodes produce PTVTRANSFORM objects, the transform recipes that dataset and dataloader nodes consume. PtvTransformsResize is one of the few transform-building nodes, sitting alongside PtvTransformsToTensor.

    How it works

    Under the hood it wraps torchvision, the standard PyTorch image tooling:

    transforms.Compose([
        transforms.Resize((height, width)),
        transforms.ToTensor()
    ])
    

    That's the whole mechanism. The output is a single PTVTRANSFORM - a callable recipe, not a transformed image - and you hand it to a dataset node (like PtvImageFolderDataset or the other Ptv dataset nodes). When the dataset loads each image, the transform runs: the image gets resized to exactly height × width, then ToTensor converts it to a C,H,W tensor with values scaled into [0, 1]. One transform node, applied consistently to every image in your training and validation sets - which is exactly what you want, because inconsistent sizes are a classic training error.

    Inputs and outputs

    Only two knobs:

    • height (INT, default 256) - target height in pixels.
    • width (INT, default 256) - target width in pixels.
    • PTVTRANSFORM output - the resize+tensor transform, ready to wire into a dataset node.

    Pick dimensions that match your model's input. The pack's example models (ConvNet, ResNet) have fixed input sizes, so match the height/width here to whatever the model expects - mismatch and you'll get shape errors at the model call.

    Installing the pack

    Install the pack once, get all ~200 nodes:

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

    Restart ComfyUI. Or ComfyUI Manager → search "ComfyUI-Pt-Wrapper" → install. It's on the Comfy Registry, so Manager handles the dependencies (pandas, scikit-learn, transformers, sentencepiece, and the rest). Because this is a training node, you'll also want the pack's example workflows from examples/workflows/ - dragging one in gets you the whole dataset→transform→dataloader→train chain pre-wired.

    Common issues

    • Wrong input size. The most common failure, and it's a shape mismatch, not a crash you'll clearly understand. The model expects, say, 96×96 but your transform outputs 256×256 - check that height/width match the model node's config.
    • Resizing distorts aspect ratios. Resize stretches to the exact box. Fine for training, but if your evaluation metrics drop, a square-crop or pad strategy may serve you better than squashing.
    • Transform not applying. The transform only runs through a dataset node that consumes PTVTRANSFORM. If you've wired the output to nothing, your images stay raw.

    It's the unglamorous but essential step: every training run that works is one where images showed up at the model in the right size. This node is how you make that true in the graph.

    CategoryTraining

    Inputs (2)

    NameTypeDefaultDescription
    heightINT2561–32768
    widthINT2561–32768

    Outputs (1)

    NameTypeDescription
    PTVTRANSFORMPTVTRANSFORM