Nodes/ComfyDL/VOC Segmentation
ComfyUI Node

VOC Segmentation

A 2 GB dataset that appears at your doorstep (and where it hides)

By Cynthia-lxx·Created 2 months ago·Updated about 16 hours ago· 6
VOC Segmentation
    • train_loader
    • test_loader
    batch_size32
    crop_height320
    crop_width480

    Semantic segmentation is the task of labeling every pixel of an image with a class - person, car, road - and the classic dataset for learning it is PASCAL VOC 2012. CdlVOCSegmentation drops that dataset into your graph with one double-click of the queue button. It downloads, extracts, and wraps VOC into train/test PyTorch DataLoaders, sized and cropped to whatever you ask for, no shell commands required.

    This is ComfyDL's dataset-loading node for segmentation, and like the rest of the pack it mirrors a "Dive into Deep Learning" (d2l) textbook section. If you've come from the image-generation side of ComfyUI you'll find this node's habit of downloading gigabytes on first run familiar - but where it puts those files probably isn't.

    How it works

    On first execution, the node fetches VOCtrainval_11-May-2012.tar (~2 GB) from the d2l data server, verifies it against a SHA-1 hash, extracts it, and then:

    • Reads the JPEG photos plus their SegmentationClass PNGs, where each pixel's RGB color encodes its class. There are 21 classes - background plus 20 objects, from aeroplane and bicycle through person and train to tv/monitor.
    • Converts that color coding to class indices using a 256³ lookup table, so every pixel becomes an integer 0–20.
    • Applies a paired random crop of crop_height × crop_width to the photo and its label together - same crop coordinates on both, so the pixel labels stay perfectly aligned with the image.
    • Normalizes the photos with ImageNet statistics (mean 0.485/0.456/0.406) and returns two DataLoaders: train_loader and test_loader (the val split).

    The three inputs are self-explanatory: batch_size (default 32), and the crop_height / crop_width (defaults 320×480). The crop sizes are worth a moment: images smaller than the crop are silently dropped from the dataset - the code filters them out - so a huge crop can quietly shrink your data. The defaults are sensible for VOC's typical landscape photos.

    The gotcha nobody puts on the tin

    The ~2 GB tar lands in a data/ folder in the parent directory of wherever you launched ComfyUI, not inside your ComfyUI install and definitely not in your models/ folder. The d2l downloader's default root is ../data, relative to the working directory, and the pack didn't override it. First run looks like it's hanging on "Downloading…" while it pulls two gigs over whatever connection you have; subsequent runs should be cached. If you're low on disk in that parent folder, clear some space before you queue.

    Also worth knowing: this depends on torchvision.io.read_image, which is available in the torchvision that ships with ComfyUI, and it uses multiprocessing workers - on Windows that can be slow and memory-hungry. Small batch sizes are your friend here; the DataLoaders hold normalized tensors, not file paths.

    What you do with the output

    The two cdlDataloader outputs plug into ComfyDL's dataset plumbing. To actually see what you loaded, wire train_loader into DataLoader Preview (Output), which renders a batch as a viewable image. Sibling nodes in the Segmentation category give you the VOC Classes list and the colormap↔label helpers if you want to decode what the loader is producing by hand. A full segmentation training loop isn't really what this pack does - this node is the "get the data, understand it, preview it" stage of the d2l semantic-segmentation chapter.

    Installing ComfyDL

    Same install as every node in the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Cynthia-lxx/ComfyDL ./ComfyDL
    pip install -r ./ComfyDL/requirements.txt
    

    Restart ComfyUI; the node lives under ComfyDL/Datasets. Folder name must stay exactly ComfyDL, and ComfyUI Manager may not list the pack yet (its registry PublisherId is blank), so cloning is the dependable route. Requirements are only matplotlib, IPython and matplotlib-inline - the heavy lifting (torch, torchvision, the downloader) comes from ComfyUI and the pack's own code.

    ComfyDL has no community footprint to lean on yet, so budget for that first-run download and treat the repo's FUNCTIONS.md plus the d2l semantic-segmentation chapter as your docs. The node is honest about what it is: a dataset faucet. Just know where the water goes.

    CategoryComfyDL/Datasets

    Inputs (3)

    NameTypeDefaultDescription
    batch_sizeINT321–128
    crop_heightINT32064–1024
    crop_widthINT48064–2048

    Outputs (2)

    NameTypeDescription
    train_loadercdlDataloader
    test_loadercdlDataloader