Nodes/ComfyUI_DAO_master/Mosaic: Assemble (Folder)
ComfyUI Node

Mosaic: Assemble (Folder)

Stitch tiled-diffusion output back into one image

By orion4d·Created about a year ago·Updated 12 months ago· 11
Mosaic: Assemble (Folder)
    • image
    • save_path
    folderoutput/tiles
    glob_pattern*.png
    rows2
    cols2
    sort_modename_asc
    order_moderow_major
    regex_rowr(\d+)
    regex_colc(\d+)
    base_index0
    fallback_orderrow_major
    offset_x0
    offset_y0
    gutter0
    overlap_x0
    overlap_y0
    overlap_blendlast
    blend_weight0.50
    feather_px0
    enforce_tile_sizetrue
    target_w0
    target_h0
    exporttrue
    filetypepng
    quality95
    basenamemosaic_from_folder
    subfolder
    bg_color#000000
    bg_alpha0

    The other half of the tiled-diffusion story. MosaicTileExport cuts an image into tiles, you process them, and MosaicAssembleFromFolder puts them back. This is the folder-based variant: instead of taking a batch tensor, it reads tiles straight from a directory - which is exactly what you want when the tiles were processed by an external tool, a second ComfyUI instance, or any pipeline that wrote files instead of keeping tensors in memory.

    How it works

    The node globs a folder for files (default output/tiles/*.png), sorts them, and places each tile onto a rows × cols canvas. The placement logic is where it gets interesting, and the star is order_mode:

    • row_major / column_major / snake_row / snake_col - the classic scan orders, for when tile order in the folder matches grid order.
    • regex_filename_order - the killer feature for real tiled-diffusion use. It parses row and column numbers out of each filename with regexes (regex_row default r(\d+), regex_col default c(\d+)) and places every tile at its exact grid position. Filenames like tile_r01_c03.png just work, regardless of folder sort order.

    It also has the blending machinery that makes overlapping tiles look like one image instead of a patchwork - that's the part the tiled-diffusion community cares about, because naive seams are the classic artifact. The overlap_blend modes include average, alpha_over, add, multiply, screen, lighten, darken, weighted, feather_linear, and feather_cosine, controlled by overlap_x/overlap_y, blend_weight, and feather_px. For a seamless stitch, feather_linear or feather_cosine with a reasonable feather_px is the mode you'll actually reach for - the KB's tiled-upscaling notes call out patchwork artifacts as the #1 thing to avoid.

    Inputs that matter

    • folder, glob_pattern - where the tiles are and what they're named.
    • rows, cols - the grid size.
    • order_mode - regex_filename_order for robustness, row_major otherwise.
    • overlap_x, overlap_y, overlap_blend, feather_px - seam handling for overlapping tiles.
    • enforce_tile_size + target_w/target_h - force every tile to a uniform size before placing (tiles that don't match get resized).
    • export + filetype/quality/basename/subfolder - whether to also save the result.

    Outputs

    image - the assembled IMAGE. save_path - the written file path when export is on.

    How to install

    Part of the orion4d/ComfyUI_DAO_master pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/orion4d/ComfyUI_DAO_master.git
    pip install -r requirements.txt
    

    Restart ComfyUI. No models.

    Common issues

    The usual failure is tile placement: if tiles are landing in wrong cells, either your filenames don't match the default r(\d+)_c(\d+) regexes (check regex_row/regex_col and base_index - zero- vs one-based counting is a classic mismatch), or you're on a plain scan order when the folder isn't sorted as expected. Empty canvas? Check glob_pattern actually matches your files. And remember the default export writes a file - if you're seeing an unexpected save, that's the export toggle.

    CategoryDAO_master/Images/Mosaic

    Inputs (28)

    NameTypeDefaultDescription
    folderSTRINGoutput/tiles
    glob_patternSTRING*.png
    rowsINT21–1024
    colsINT21–1024
    sort_modeoptCOMBOname_asc4 options: name_asc, name_desc, mtime_asc, mtime_desc
    order_modeoptCOMBOrow_major5 options: row_major, column_major, snake_row, snake_col, regex_filename_order
    regex_rowoptSTRINGr(\d+)
    regex_coloptSTRINGc(\d+)
    base_indexoptINT00–10
    fallback_orderoptCOMBOrow_major4 options: row_major, column_major, snake_row, snake_col
    offset_xoptINT0-10000–10000
    offset_yoptINT0-10000–10000
    gutteroptINT0-4096–4096
    overlap_xoptINT00–4096
    overlap_yoptINT00–4096
    overlap_blendoptCOMBOlast13 options: last, average, alpha_over, add, multiply, screen, +7
    blend_weightoptFLOAT0.500–1
    feather_pxoptINT00–2048
    enforce_tile_sizeoptBOOLEANtrue
    target_woptINT00–8192
    target_hoptINT00–8192
    exportoptBOOLEANtrue
    filetypeoptCOMBOpng2 options: png, jpg
    qualityoptINT951–100
    basenameoptSTRINGmosaic_from_folder
    subfolderoptSTRING
    bg_coloroptSTRING#000000
    bg_alphaoptINT00–255

    Outputs (2)

    NameTypeDescription
    imageIMAGE
    save_pathSTRING