Nodes/ComfyUI-DataSet/DataSet_PathSelector
ComfyUI Node

DataSet_PathSelector

Find the Orphaned Images (or Missing Captions) in Your Dataset

By daxcay·Created 2 years ago·Updated about a year ago· 58
DataSet_PathSelector
    • SelectedNamesWithExtension
    • SelectedNamesWithoutExtension
    • SelectedPaths
    â—„search_in_directoryâ–º
    â—„search_for_extensionsâ–º
    â—„select_from_directoryâ–º
    â—„select_extensionsâ–º

    Datasets rot. You copy a hundred images one day, caption them another, and eventually there's a subfolder where half the images have no caption file and a bunch of caption files have no image. DataSet_PathSelector is the node that finds the holes: it scans one directory for files that are missing their pair in another, then hands you the paths and names of the files you need to pull across.

    The README describes it as the tool for "identifying images in a sub-dataset which are missing caption text files from a larger parent repository of image-text pairings." Concretely: you have a master dataset with photo_001.png + photo_001.txt pairs, and a sub-dataset where some .txt files are missing. This node tells you exactly which caption files are needed, by name and full path, so you can copy them in.

    How it works

    The logic is a two-step matching:

    1. In search_in_directory, it lists every file matching search_for_extensions (e.g. .png, .jpg) and collects their base names - these are the "orphaned" files that need a partner.
    2. In select_from_directory, it lists every file matching select_extensions (e.g. .txt, .csv) and looks for base names that match step 1's orphans.

    Anything that matches is returned. So: "which of my master .txt files correspond to images that are currently missing captions in my sub-dataset?"

    Inputs and outputs

    Four string inputs, all plain paths and extension lists (comma-separated, with or without leading dots - txt and .txt both work):

    • search_in_directory - the folder with the orphaned files.
    • search_for_extensions - the orphaned files' extensions.
    • select_from_directory - the master folder with the complete pairs.
    • select_extensions - the extensions of the files to find.

    Three list outputs:

    • SelectedNamesWithExtension - photo_001.txt etc.
    • SelectedNamesWithoutExtension - photo_001.
    • SelectedPaths - full paths into the master directory, ready to feed a loader or copy step.

    The names-without-extension output is the one to wire into DataSet_CopyFiles or a save node if you're auto-repairing the dataset.

    Installing

    Part of the ComfyUI-DataSet pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-DataSet.git
    cd ComfyUI-DataSet && pip install -r requirements.txt
    

    Restart ComfyUI. Pure filesystem logic, no models, no dependencies beyond stdlib.

    Common issues

    The matching is by base name only - it ignores everything about the files except their stems. If your master dataset has photo_001.jpg and photo_001.png both with matching captions, both count as matches and you'll get duplicates in the output. Also, if either directory doesn't exist, the node quietly returns three empty lists and prints to the console - it won't error visibly. The tell-tale is empty outputs, and it's worth checking paths first.

    That said, for the specific job of "which caption files am I missing," it's genuinely handy. Run it, grab SelectedPaths, copy them over, and your dataset is whole again - no eyeballing directory listings at 1am.

    Category🔶DATASET🔶

    Inputs (4)

    NameTypeDefaultDescription
    search_in_directorySTRING—
    search_for_extensionsSTRING—
    select_from_directorySTRING—
    select_extensionsSTRING—

    Outputs (3)

    NameTypeDescription
    SelectedNamesWithExtensionSTRING—
    SelectedNamesWithoutExtensionSTRING—
    SelectedPathsSTRING—