Nodes/Diffusion_pipe_in_ComfyUI/训练采样器配置(开发版)
ComfyUI Node

训练采样器配置(开发版)

Schedule validation images while training runs

By TianDongL·Created 11 months ago·Updated 7 months ago· 69
训练采样器配置(开发版)
    • sampler_config
    sample_every_n_steps0
    sample_every_n_epochs1
    num_inference_steps20
    guidance_scale5.0
    guidance_value4.0
    height1024
    width1024
    sample_prompt

    A multi-hour training run that produces nothing you can look at until the end is a gamble. TrainingSamplerConfig is the node that removes the blindfold: it schedules the trainer to generate sample images from your model at set intervals, so you can watch the concept actually forming - or detect a collapsed run before you've wasted six hours. The display name is honest about its status: "训练采样器配置(开发版)", the dev-version training sampler.

    How it works

    This node produces a sampler_config - in practice a JSON string of sampling settings - that GeneralConfig (or AdvancedTrainConfig) folds into the training config. When the trainer hits the interval you set, it pauses briefly, runs the model on a validation prompt at your chosen resolution, and saves the result into the output directory where your TensorBoard dashboard picks it up.

    Two knobs control when sampling happens, and they're mutually independent:

    • sample_every_n_steps - sample every N training steps. 0 disables step-based sampling.
    • sample_every_n_epochs - sample every N epochs. Default 1, which is why you'll get periodic samples even if you never touch this node.

    Everything else controls what the sample looks like.

    The inputs that matter

    • sample_every_n_steps / sample_every_n_epochs - the two scheduling knobs above.
    • num_inference_steps - default 20, how many denoising steps each sample gets. Lower = faster previews, rougher images.
    • guidance_scale - default 5.0, the CFG strength for the sample.
    • height / width - default 1024 × 1024, sample resolution. Match your training resolution or the previews won't represent what the model is learning.
    • sample_prompt - the prompt used for samples. Leave it empty and it falls back to a caption from your training data, which is often better for seeing what the LoRA has learned - your trigger-word captions are what it's actually training on.

    Install

    The usual: ComfyUI Manager → search "Diffusion_pipe_in_ComfyUI", or:

    cd ComfyUI/custom_nodes
    git clone --recurse-submodules https://github.com/TianDongL/Diffusion_pipe_in_ComfyUI.git
    cd Diffusion_pipe_in_ComfyUI
    git submodule init && git submodule update
    pip install -r requirements.txt
    

    Linux/WSL2 only, as always with this pack.

    Where people get burned

    Sampling costs VRAM and time inside an already-expensive run. If your run keeps dying right after a "sample" appears in the logs, the sampler is likely the culprit - drop sample_every_n_steps to 0 and sample only per-epoch. Also note it's a dev-version node, so don't be shocked if behavior shifts between pack updates. And the preview resolution trap: leave the sample at 1024×1024 while training at 512 and the previews will look "wrong" even though the training is fine. Match them.

    CategoryDiffusion-Pipe/Config

    Inputs (8)

    NameTypeDefaultDescription
    sample_every_n_stepsoptINT00–10000每N步采样一次图片,0表示禁用按步数采样
    sample_every_n_epochsoptINT10–100每N个epoch采样一次图片,0表示禁用按epoch采样
    num_inference_stepsoptINT201–100推理采样步数
    guidance_scaleoptFLOAT5.00–20CFG引导强度 (Classifier-Free Guidance Scale)
    guidance_valueoptFLOAT4.00–10模型内部的guidance参数值
    heightoptINT1024256–4096采样图片高度
    widthoptINT1024256–4096采样图片宽度
    sample_promptoptSTRING采样时使用的提示词(留空则使用训练数据的caption)

    Outputs (1)

    NameTypeDescription
    sampler_configSAMPLER_CONFIG